[
http://opensource.atlassian.com/projects/hibernate/browse/HBX-1075?page=c...
]
louie updated HBX-1075:
-----------------------
Attachment: test-case.zip
Attached is the complete package containing both working single-table inheritance and
NOT-WORKING single-table inheritance cases.
Also, the ant build script and build output message are attached in this package. Unzip
this package and run ant will generate the same message.
Please let us know if you need more information.
Single table inhertance failed on hbm2ddl
-----------------------------------------
Key: HBX-1075
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HBX-1075
Project: Hibernate Tools
Issue Type: Bug
Affects Versions: 3.2.1
Reporter: louie
Attachments: test-case.zip
We are reporting an issue during the database schema generating process using hbm2ddl
tools against some entities using single-table inheritance strategy. It works fine for the
simple hierarchy entity mappings. It breaks down when we try to modeling the data using
single-table inheritance in relational entities. Here is one example:
The main object:
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorValue("S")
public class MySub1 extends AbstractMySuper {
@ManyToOne(fetch = FetchType.EAGER)
private MySub1 underlying;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER,
mappedBy="mysub1")
private List<ExcludedMySub1> excludedSub1;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER,
mappedBy="mysub1")
private List<IncludedMySub1> includedSub1;
...
}
The relationship super-class:
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="myType",discriminatorType=DiscriminatorType.STRING,
length=1)
public abstract class AbstractMySub1 {
@Id
@SequenceGenerator(name = "AbstractMySub1", sequenceName =
"AbstractMySub1_id")
@GeneratedValue(generator = "AbstractMySub1")
@Column(precision=5)
private int id;
@ManyToOne(cascade={CascadeType.PERSIST,CascadeType.MERGE, CascadeType.REFRESH})
private MySub1 mysub1;
...
}
The relationship sub-classes:
@Entity
@DiscriminatorValue("I")
public class IncludedMySub1 extends AbstractMySub1 {
}
@Entity
@DiscriminatorValue("E")
public class ExcludedMySub1 extends AbstractMySub1 {
}
I got the following error:
[hibernatetool] Problems in creating a configuration for JPA. Have you remembered to add
hibernate EntityManager jars to the classpath ?
[hibernatetool] java.lang.reflect.InvocationTargetException
[hibernatetool] javax.persistence.PersistenceException:
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property:
ExcludedMySub1.mysub1 in MySub1.excludedSub1
[hibernatetool] org.hibernate.AnnotationException: mappedBy reference an unknown target
entity property: ExcludedMySub1.mysub1 in MySub1.excludedSub1
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error executing ant tasks
Embedded error: Problems in creating a configuration for JPA. Have you remembered to add
hibernate EntityManager jars to the classpath ?
mappedBy reference an unknown target entity property: ExcludedMySub1.mysub1 in
MySub1.excludedSub1
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Error executing ant tasks
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:583)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error executing ant tasks
at
org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:114)
at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:83)
at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
... 16 more
Caused by: Problems in creating a configuration for JPA. Have you remembered to add
hibernate EntityManager jars to the classpath ?
at
org.hibernate.tool.ant.JPAConfigurationTask.createConfiguration(JPAConfigurationTask.java:57)
at
org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:54)
at
org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
at
org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:64)
at net.sf.antcontrib.logic.IfTask.execute(IfTask.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:123)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at
org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:108)
... 19 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.hibernate.tool.ant.JPAConfigurationTask.createConfiguration(JPAConfigurationTask.java:43)
... 36 more
Caused by: javax.persistence.PersistenceException: org.hibernate.AnnotationException:
mappedBy reference an unknown target entity property: ExcludedMySub1.mysub1 in
MySub1.excludedSub1
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:258)
... 41 more
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity
property:ExcludedMySub1.mysub1 in MySub1.excludedSub1
at
org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:552)
at
org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:517)
at
org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1136)
at
org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:316)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1121)
at
org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1269)
at
org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:150)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:888)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:186)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:246)
... 41 more
[INFO] ------------------------------------------------------------------------
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira