java - Hibernate MappedSuperClass in another project -
we building complex project consist of multiple projects. , amongst these projects, 2 of them used defining base entities (like interfaces).
normally, if these projects 1 run without error codes below.
but these codes placed in seperate projects, entities derived superclass (from baseentity) causing error :
caused by: org.hibernate.annotationexception: no identifier specified entity: com.unalcable.department.security.model.approvalhistory
so i've searched causes, , i've found out defining baseentity in hibernate's configuration concrete class other fix it. didn't...
here codes :
hibernate's configuration
<bean id="sessionfactory" class="org.springframework.orm.hibernate4.localsessionfactorybean"> <property name="datasource" ref="datasource" /> <property name="annotatedclasses"> <list> <value>com.unalcable.general.common.model.baseentity</value> <value>com.unalcable.department.security.model.approvalhistory</value> <value>com.unalcable.department.security.model.carvisitorrequest</value> <value>com.unalcable.department.security.model.humanvisitorrequest</value> <value>com.unalcable.department.security.model.privilige</value> <value>com.unalcable.department.security.model.visitor</value> </list> </property> <property name="hibernateproperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">${hibernate.showsql}</prop> <prop key="hibernate.hbm2ddl.auto">${hibernate.action}</prop> <prop key="hibernate.format_sql">${hibernate.format_sql}</prop> <prop key="hibernate.use_sql_comments">${hibernate.use_sql_comments}</prop> <prop key="hibernate.globally_quoted_identifiers">true</prop> </props> </property> </bean>
baseentity.java (in project 1)
@mappedsuperclass @access(accesstype.property) public class baseentity implements serializable { public static final long serialversionuid = 1l; public long id; public string tostring() { return tostringbuilder.reflectiontostring(this, tostringstyle.default_style); } public boolean equals(object obj) { boolean result = false; if (obj instanceof baseentity) { baseentity other = (baseentity)obj; if (other.getid().equals(this.getid())) result = true; } return result; } public string todebugstring() { return tostringbuilder.reflectiontostring(this, tostringstyle.default_style); } @id @generatedvalue public long getid() { return id; } public void setid(long id) { this.id = id; } }
approvalhistory.java(project 2)
@entity public class approvalhistory extends baseentity { public long date; public user user; @enumerated(enumtype.string) public approvalstate approvalstate; public long getdate() { return date; } public void setdate(long date) { this.date = date; } public user getuser() { return user; } public void setuser(user user) { this.user = user; } public approvalstate getapprovalstate() { return approvalstate; } public void setapprovalstate(approvalstate approvalstate) { this.approvalstate = approvalstate; } }
** projects refer necessary projects in build path. tomcat has these projects in classpath **
the error might caused mixed access type. baseentity declares @access(accesstype.property)
while approvalhistory has annotated field hibernate assumes uses field access type. i'm not sure this, may trying apply field access base entity well, not finding identifier.
try moving @enumerated
annotation getapprovalstate()
method see if case.
Comments
Post a Comment