[hibernate-issues] [Hibernate-JIRA] Created: (EJB-371) Hibernate dose not support the single-table inheritance strategy for relational entities
louie (JIRA)
noreply at atlassian.com
Tue Jul 15 13:27:42 EDT 2008
Hibernate dose not support the single-table inheritance strategy for relational entities
----------------------------------------------------------------------------------------
Key: EJB-371
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-371
Project: Hibernate Entity Manager
Issue Type: Bug
Components: EntityManager
Affects Versions: 3.4.0.CR1
Environment: hibernate-annotations-3.4.0.CR1, hibernate-conmmons-annotations-3.1.0.CR1,hibernate-tools-3.2.0.GA
Reporter: louie
Attachments: test-case.zip
Hibernate EJB configuration failed in the case of single-table inheritance strategy for relational entities. Here is the use case:
@Entity
public class User {
@Id
@SequenceGenerator(name = "user", sequenceName = "user_id")
@GeneratedValue(generator = "user")
private int id;
private String name;
@OneToMany(mappedBy = "user")
private List<ExcludedGroupUser> excludedUsers;
@OneToMany(mappedBy = "user")
private List<IncludedGroupUser> includedUsers;
...
}
@Entity
public class Group {
@Id
@SequenceGenerator(name = "group", sequenceName = "group_id")
@GeneratedValue(generator = "group")
private int id;
private String name;
@ManyToOne(fetch = FetchType.EAGER)
private Group underlying;
/** list of user belong to underlying group, but not belongs to this group */
@OneToMany(mappedBy = "group")
private List<ExcludedGroupUser> excludedUsers;
/** list of user belong to this group **/
@OneToMany(mappedBy = "group")
private List<IncludedGroupUser> includedUsers;
...
}
The main relational entity:
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="groupType",discriminatorType=DiscriminatorType.STRING, length=1)
public class GroupUser {
@Id
@SequenceGenerator(name = "groupUser", sequenceName = "groupUser_id")
@GeneratedValue(generator = "groupUser")
private int id;
@ManyToOne
private Group group;
@ManyToOne
private User user;
...
}
The subclasses:
@Entity
@DiscriminatorValue("I")
public class IncludedGroupUser extends GroupUser{
}
and
@Entity
@DiscriminatorValue("E")
public class ExcludedGroupUser extends GroupUser {
}
The build output error message:
C:\workspaces\test-case\test-case>ant -verbose
Apache Ant version 1.6.5 compiled on June 2 2005
Buildfile: build.xml
Detected Java version: 1.5 in: C:\Program Files\Java\jdk1.6.0_05\jre
Detected OS: Windows XP
parsing buildfile C:\workspaces\test-case\test-case\build.xml with URI = file:///C:/workspaces/test-
case/test-case/build.xml
Project base dir set to: C:\workspaces\test-case\test-case
Build sequence for target(s) `compile' is [clean, copy-resources, compile]
Complete build sequence is [clean, copy-resources, compile, ]
clean:
[delete] Deleting directory C:\workspaces\test-case\test-case\bin
[delete] Deleting C:\workspaces\test-case\test-case\bin\META-INF\persistence.xml
[delete] Deleting directory C:\workspaces\test-case\test-case\bin\META-INF
[delete] Deleting C:\workspaces\test-case\test-case\bin\notWorking\ExcludedGroupUser.class
[delete] Deleting C:\workspaces\test-case\test-case\bin\notWorking\Group.class
[delete] Deleting C:\workspaces\test-case\test-case\bin\notWorking\GroupUser.class
[delete] Deleting C:\workspaces\test-case\test-case\bin\notWorking\IncludedGroupUser.class
[delete] Deleting C:\workspaces\test-case\test-case\bin\notWorking\User.class
[delete] Deleting directory C:\workspaces\test-case\test-case\bin\notWorking
[delete] Deleting C:\workspaces\test-case\test-case\bin\working\Employee.class
[delete] Deleting C:\workspaces\test-case\test-case\bin\working\FullTimeEmployee.class
[delete] Deleting C:\workspaces\test-case\test-case\bin\working\PartTimeEmployee.class
[delete] Deleting directory C:\workspaces\test-case\test-case\bin\working
[delete] Deleting directory C:\workspaces\test-case\test-case\bin
[mkdir] Created dir: C:\workspaces\test-case\test-case\bin
copy-resources:
[copy] META-INF\persistence.xml added as META-INF/persistence.xml doesn't exist.
[copy] omitted as is up to date.
[copy] META-INF added as META-INF doesn't exist.
[copy] notWorking added as notWorking doesn't exist.
[copy] working added as working doesn't exist.
[copy] Copying 1 file to C:\workspaces\test-case\test-case\bin
[copy] Copying C:\workspaces\test-case\test-case\src\META-INF\persistence.xml to C:\workspaces\
test-case\test-case\bin\META-INF\persistence.xml
[copy] Copied 3 empty directories to 2 empty directories under C:\workspaces\test-case\test-cas
e\bin
compile:
[javac] META-INF\persistence.xml skipped - don't know how to handle it
[javac] notWorking\ExcludedGroupUser.java added as notWorking/ExcludedGroupUser.class doesn't ex
ist.
[javac] notWorking\Group.java added as notWorking/Group.class doesn't exist.
[javac] notWorking\GroupUser.java added as notWorking/GroupUser.class doesn't exist.
[javac] notWorking\IncludedGroupUser.java added as notWorking/IncludedGroupUser.class doesn't ex
ist.
[javac] notWorking\User.java added as notWorking/User.class doesn't exist.
[javac] working\Employee.java added as working/Employee.class doesn't exist.
[javac] working\FullTimeEmployee.java added as working/FullTimeEmployee.class doesn't exist.
[javac] working\PartTimeEmployee.java added as working/PartTimeEmployee.class doesn't exist.
[javac] Compiling 8 source files to C:\workspaces\test-case\test-case\bin
[javac] Using modern compiler
[javac] Compilation arguments:
[javac] '-d'
[javac] 'C:\workspaces\test-case\test-case\bin'
[javac] '-classpath'
[javac] 'C:\workspaces\test-case\test-case\bin;C:\workspaces\test-case\test-case\lib\antlr-2.7.6
.jar;C:\workspaces\test-case\test-case\lib\commons-collections-3.1.jar;C:\workspaces\test-case\test-
case\lib\commons-logging-1.1.1.jar;C:\workspaces\test-case\test-case\lib\dom4j-1.6.1.jar;C:\workspac
es\test-case\test-case\lib\freemarker.jar;C:\workspaces\test-case\test-case\lib\hibernate-annotation
s.jar;C:\workspaces\test-case\test-case\lib\hibernate-commons-annotations.jar;C:\workspaces\test-cas
e\test-case\lib\hibernate-entitymanager.jar;C:\workspaces\test-case\test-case\lib\hibernate-tools.ja
r;C:\workspaces\test-case\test-case\lib\hibernate3.jar;C:\workspaces\test-case\test-case\lib\javassi
st-3.6.0.GA.jar;C:\workspaces\test-case\test-case\lib\jboss-archive-browsing.jar;C:\workspaces\test-
case\test-case\lib\log4j-1.2.15.jar;C:\workspaces\test-case\test-case\lib\ojdbc14.jar;C:\workspaces\
test-case\test-case\lib\persistence-api.jar;C:\workspaces\test-case\test-case\lib\slf4j-api-1.4.2.ja
r;C:\workspaces\test-case\test-case\lib\slf4j-log4j12-1.5.2.jar;C:\apache-ant-1.6.5\lib\ant-launcher
.jar;C:\workspaces\test-case\test-case;C:\Program Files\Java\jre1.6.0_05\lib\ext\QTJava.zip;C:\apach
e-ant-1.6.5\lib\ant-antlr.jar;C:\apache-ant-1.6.5\lib\ant-apache-bcel.jar;C:\apache-ant-1.6.5\lib\an
t-apache-bsf.jar;C:\apache-ant-1.6.5\lib\ant-apache-log4j.jar;C:\apache-ant-1.6.5\lib\ant-apache-oro
.jar;C:\apache-ant-1.6.5\lib\ant-apache-regexp.jar;C:\apache-ant-1.6.5\lib\ant-apache-resolver.jar;C
:\apache-ant-1.6.5\lib\ant-commons-logging.jar;C:\apache-ant-1.6.5\lib\ant-commons-net.jar;C:\apache
-ant-1.6.5\lib\ant-icontract.jar;C:\apache-ant-1.6.5\lib\ant-jai.jar;C:\apache-ant-1.6.5\lib\ant-jav
amail.jar;C:\apache-ant-1.6.5\lib\ant-jdepend.jar;C:\apache-ant-1.6.5\lib\ant-jmf.jar;C:\apache-ant-
1.6.5\lib\ant-jsch.jar;C:\apache-ant-1.6.5\lib\ant-junit.jar;C:\apache-ant-1.6.5\lib\ant-netrexx.jar
;C:\apache-ant-1.6.5\lib\ant-nodeps.jar;C:\apache-ant-1.6.5\lib\ant-starteam.jar;C:\apache-ant-1.6.5
\lib\ant-stylebook.jar;C:\apache-ant-1.6.5\lib\ant-swing.jar;C:\apache-ant-1.6.5\lib\ant-trax.jar;C:
\apache-ant-1.6.5\lib\ant-vaj.jar;C:\apache-ant-1.6.5\lib\ant-weblogic.jar;C:\apache-ant-1.6.5\lib\a
nt-xalan1.jar;C:\apache-ant-1.6.5\lib\ant-xslp.jar;C:\apache-ant-1.6.5\lib\ant.jar;C:\apache-ant-1.6
.5\lib\jaxws-tools.jar;C:\apache-ant-1.6.5\lib\xercesImpl.jar;C:\apache-ant-1.6.5\lib\xml-apis.jar;C
:\Program Files\Java\jdk1.6.0_05\lib\tools.jar'
[javac] '-sourcepath'
[javac] 'C:\workspaces\test-case\test-case\src'
[javac] '-g:none'
[javac]
[javac] The ' characters around the executable and arguments are
[javac] not part of the command.
[javac] Files to be compiled:
[javac] C:\workspaces\test-case\test-case\src\notWorking\ExcludedGroupUser.java
[javac] C:\workspaces\test-case\test-case\src\notWorking\Group.java
[javac] C:\workspaces\test-case\test-case\src\notWorking\GroupUser.java
[javac] C:\workspaces\test-case\test-case\src\notWorking\IncludedGroupUser.java
[javac] C:\workspaces\test-case\test-case\src\notWorking\User.java
[javac] C:\workspaces\test-case\test-case\src\working\Employee.java
[javac] C:\workspaces\test-case\test-case\src\working\FullTimeEmployee.java
[javac] C:\workspaces\test-case\test-case\src\working\PartTimeEmployee.java
Property ${libraries} has not been set
[hibernatetool] Executing Hibernate Tool with a JPA Configuration
dropping C:\workspaces\test-case\test-case\${libraries} from path as it doesn't exist
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
[hibernatetool] log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Ver
sion).
[hibernatetool] log4j:WARN Please initialize the log4j system properly.
[hibernatetool] An exception occurred while running exporter #2:hbm2ddl (Generates database schema)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] Problems in creating a configuration for JPA. Have you remembered to add hibernate E
ntityManager jars to the classpath ?
[hibernatetool] java.lang.reflect.InvocationTargetException
[hibernatetool] javax.persistence.PersistenceException: org.hibernate.AnnotationException: mappedBy
reference an unknown target entity property: notWorking.ExcludedGroupUser.user in notWorking.User.ex
cludedUsers
[hibernatetool] org.hibernate.AnnotationException: mappedBy reference an unknown target entity prope
rty: notWorking.ExcludedGroupUser.user in notWorking.User.excludedUsers
BUILD FAILED
C:\workspaces\test-case\test-case\build.xml:28: Problems in creating a configuration for JPA. Have y
ou 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.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
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)
... 16 more
Caused by: javax.persistence.PersistenceException: org.hibernate.AnnotationException: mappedBy refer
ence an unknown target entity property: notWorking.ExcludedGroupUser.user in notWorking.User.exclude
dUsers
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:258)
... 21 more
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property:
notWorking.ExcludedGroupUser.user in notWorking.User.excludedUsers
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.
java:576)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:541)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1140)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:
319)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1125)
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)
... 21 more
--- Nested Exception ---
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)
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.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: javax.persistence.PersistenceException: org.hibernate.AnnotationException: mappedBy refer
ence an unknown target entity property: notWorking.ExcludedGroupUser.user in notWorking.User.exclude
dUsers
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:258)
... 21 more
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property:
notWorking.ExcludedGroupUser.user in notWorking.User.excludedUsers
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.
java:576)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:541)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1140)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:
319)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1125)
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)
... 21 more
Total time: 2 seconds
--
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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list