Announcement Announcement Module
Collapse
No announcement yet.
mapping with a join table Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • mapping with a join table

    Hi, i want to map a composite pattern, using manytoone and onTomany association, with a join table, and im getting the following error:
    Is there any problem with my mapping?

    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in URL [file:/C:/workspace/ssd1.3/build/classes/services-config.xml]: Invocation of init method failed; nested exception is org.hibernate.AssertionFailure: Table DOCUMENTOS_DOCUMENTOSCOMPUESTOS not found
    Caused by: org.hibernate.AssertionFailure: Table DOCUMENTOS_DOCUMENTOSCOMPUESTOS not found
    	at org.hibernate.persister.entity.JoinedSubclassEntityPersister.getTableId(JoinedSubclassEntityPersister.java:458)
    	at org.hibernate.persister.entity.JoinedSubclassEntityPersister.<init>(JoinedSubclassEntityPersister.java:237)
    	at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:58)
    	at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
    	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
    	at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
    	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:730)
    	at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:127)
    	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:214)
    	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:251)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1143)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1110)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:431)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:254)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:144)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:251)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
    	at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:104)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1101)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:431)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:254)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:144)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:251)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
    	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:683)
    	at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:451)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:337)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at org.springframework.test.jpa.AbstractJpaTests.runBare(AbstractJpaTests.java:214)
    	at junit.framework.TestResult$1.protect(TestResult.java:106)
    	at junit.framework.TestResult.runProtected(TestResult.java:124)
    	at junit.framework.TestResult.run(TestResult.java:109)
    	at junit.framework.TestCase.run(TestCase.java:118)
    	at junit.framework.TestSuite.runTest(TestSuite.java:208)
    	at junit.framework.TestSuite.run(TestSuite.java:203)
    	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
    	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    Code:
    @Entity
    @Table(name="DOCUMENTOS")
    @Inheritance(strategy = InheritanceType.JOINED)
    @org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = false)
    public abstract class Documento extends Entidad {
    	
    	private Documento padre;
    
    	@ManyToOne
    	@JoinTable (
    	        name = "DOCUMENTOS_DOCUMENTOSCOMPUESTOS",
    	        joinColumns = @JoinColumn (name = "DOCUMENTOS_ID"),
    	        inverseJoinColumns = @JoinColumn (name = "DOCUMENTOSCOMPUESTOS_ID")
    	)
    	public Documento getPadre() {
    		return padre;
    	}
    Code:
    @Entity
    @Table(name = "DOCUMENTOSCOMPUESTOS")
    @org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = false)
    public abstract class DocumentoCompuesto extends Documento {
    	
    	private List<Documento> documentos = new ArrayList<Documento>();
    
    	@OneToMany(mappedBy = "padre")
    	public List<Documento> getDocumentos() {
    		return documentos;
    	}

    Thanks!!

  • #2
    Hi, yes i know that the table is missing, but do i have to create it manually?
    or hibernate creates it for me?
    I have worked others example where the join table is created automaticcally
    (setting generated ddl = true), but in this particular example it doesn't work.

    Chau!!

    Comment

    Working...
    X