Hibernate pagination ORA-00918: column ambiguously defined - java

When hibernate tries to paginate an entity generated using the following hbm.xml, it throws up column ambiguously defined.
<class lazy="false" dynamic-update="true" optimistic-lock="all" table="A" name="org.package.Entity">
<cache usage="read-write"/>
<id unsaved-value="null" type="java.lang.Long" name="aId">
<column name="ID_A" not-null="true" sql-type="java.lang.Long"/>
<generator class="org.package.Entity"/>
</id>
<property type="java.lang.Long" name="aGroupId" not-null="true">
<column name="ID_GROUP" not-null="true" sql-type="java.lang.Long"/>
</property>
<property type="java.lang.String" name="statusCode" not-null="true">
<column name="CD_STATUS" not-null="true" sql-type="char(30)" length="30"/>
</property>
<property type="java.lang.Long" name="templateId" not-null="false">
<column name="ID_TEMPLATE" not-null="false" sql-type="java.lang.Long"/>
</property>
<many-to-one name="aGroup" cascade="none" column="Id_Group"
class="org.package.Entity"
insert="false" update="false"/>
<many-to-one name="template" cascade="none" column="ID_TEMPLATE"
class="org.package.Entity"
insert="false" update="false"/>
</class>
What is wrong with this entity definition?
Edit: Turning it into QandA format.

ID_TEMPLATE is being condensed into one column in the query, ID_GROUP isn't.
Hibernate uses a direct string comparison to see if two properties depend on the same column. This is case sensitive, so ID_GROUP was being selected a second time as Id_Group.
Changing the cases to match, it worked.
<class lazy="false" dynamic-update="true" optimistic-lock="all" table="A" name="org.package.Entity">
<cache usage="read-write"/>
<id unsaved-value="null" type="java.lang.Long" name="aId">
<column name="ID_A" not-null="true" sql-type="java.lang.Long"/>
<generator class="org.package.Entity"/>
</id>
<property type="java.lang.Long" name="aGroupId" not-null="true">
<column name="ID_GROUP" not-null="true" sql-type="java.lang.Long"/>
</property>
<property type="java.lang.String" name="statusCode" not-null="true">
<column name="CD_STATUS" not-null="true" sql-type="char(30)" length="30"/>
</property>
<property type="java.lang.Long" name="templateId" not-null="false">
<column name="ID_TEMPLATE" not-null="false" sql-type="java.lang.Long"/>
</property>
<many-to-one name="aGroup" cascade="none" column="ID_GROUP"
class="org.package.Entity"
insert="false" update="false"/>
<many-to-one name="template" cascade="none" column="ID_TEMPLATE"
class="org.package.Entity"
insert="false" update="false"/>
</class>
Maintaining old code is fun. Hope this helps someone.

Related

Hibernate duplicates record along with null value(new row as duplicate) while saving

I am getting following issue while saving entity in hibernate -
It duplicates the record with null values -
(2661956,2601555,'Chloe','Chloe','Thooks',null,null,null,null,null,null,'Y','N','XYZ',to_date('15-NOV-16','DD-MON-RR'),null,null)
with a duplicate -
(2661946,2601555,null,null,null,null,null,null,null,null,null,'Y','N','XYZ',to_date('15-NOV-16','DD-MON-RR'),null,null) -
We have the following mapping -
Parent -
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false">
<class name="com.sm.persistence.LOADetailBO" table="LOADETAILS">
<id name="loaDetailsId" type="long">
<column name="LOA_ID" precision="38" scale="0"/>
<generator class="com.sm.persistence.dao.seqgen.LOADetailSeqGen">
</generator>
</id>
<many-to-one name="reregistration" class="com.sm.persistence.RerBO" fetch="join">
<column name="RER_ID" precision="38" scale="0"/>
</many-to-one>
<property name="relatedPlanManager" type="string">
<column name="RELATED_PLAN_MANAGER"/>
</property>
<property name="relatedPlanManagerCode" type="string">
<column name="RELATED_PLAN_MANAGER_CODE"/>
</property>
<set name="relatedPlanManagerAddress" inverse="true" cascade="all-delete-orphan">
<key>
<column name="LOA_ID" precision="38" scale="0" not-null="false"/>
</key>
<one-to-many class="com.sm.persistence.AddressBO" />
</set>
<set name="corporateCustomers" inverse="true" cascade="all-delete-orphan">
<key>
<column name="LOA_ID" precision="38" scale="0" not-null="false"/>
</key>
<one-to-many class="com.sm.persistence.CorporateCustomerBO" />
</set>
<set name="privateCustomers" inverse="true" cascade="all-delete-orphan">
<key>
<column name="LOA_ID" precision="38" scale="0" not-null="false" />
</key>
<one-to-many class="com.sm.persistence.PrivateCustomerBO"/>
</set>
<set name="unwrappedAccount" inverse="true" cascade="all-delete-orphan">
<key>
<column name="LOA_ID" precision="38" scale="0" not-null="false"/>
</key>
<one-to-many class="com.sm.persistence.UnwrappedAccountBO" />
</set>
<set name="wrappedAccount" inverse="true" cascade="all-delete-orphan">
<key>
<column name="LOA_ID" precision="38" scale="0" not-null="false" />
</key>
<one-to-many class="com.sm.persistence.WrappedAccountBO"/>
</set>
</class>
</hibernate-mapping>
Child -
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false">
<class name="com.sm.persistence.PrivateCustomerBO" table="RER_CUSTOMER_DETAIL">
<id name="privateCustomerId" type="long">
<column name="RERE_CUSTOMER_ID" precision="38" scale="0"/>
<generator class="com.sm.persistence.dao.seqgen.PrivateCustomerSeqGen">
</generator>
</id>
<many-to-one name="loaDetail" class="com.sm.persistence.LOADetailBO" fetch="join">
<column name="LOA_DETAILS_ID" precision="38" scale="0"/>
</many-to-one>
<property name="title" type="string">
<column name="TITLE"/>
</property>
<property name="firstName" type="string">
<column name="FIRST_NAME"/>
</property>
<property name="surname" type="string">
<column name="SURNAME"/>
</property>
<set name="address" inverse="false" cascade="all-delete-orphan">
<key>
<column name="PRIVATE_CUSTOMER_ID" precision="38" scale="0" not-null="false"/>
</key>
<one-to-many class="com.sm.persistence.AddressBO" />
</set>
<property name="primary" type="string">
<column name="IS_PRIMARY"/>
</property>
<property name="corporate" type="string">
<column name="IS_CORPORATE"/>
</property>
<!--<property name="dateofBirth" type="string">
<column name="DATE_OF_BIRTH"/>
</property>-->
<property name="nationalInsurance" type="string">
<column name="NINO"/>
</property>
</class>
</hibernate-mapping>
I checked parent object both pre and post save and can't find any object with null value populated. However, when I fetch the object hierarchy with criteria api it returns duplicate record with null.
Please guide.
Quick answer:
PrivateCustomerBO is a child of LOADetailBO. So when your java code
saves a PrivateCustomerBO object it will write to all tables
specified against these 2 objects: RER_CUSTOMER_DETAIL = primary
table for PrivateCustomerBO, LOADETAILS = primary table for
LOADetailBO, plus all tables referenced by these two objects via
many-to-one or one-to-many mappings. CORRECT BEHAVIOUR
Expanding the bolded bit above, LOADetailBO is referenced by
PrivateCustomerBO via:
<many-to-one name="loaDetail" class="com.sm.persistence.LOADetailBO" fetch="join">
<column name="LOA_DETAILS_ID" precision="38" scale="0"/>
</many-to-one>
This means that LOADETAILS is additionally referenced as a related
table, not just a parent and a second row is written (in this case
there is some data missing (NULL) because your program hasn't
populated it for the referenced entity). INCORRECT BEHAVIOUR.
Fix: remove the many-to-one mapping shown above (it's redundant and covered by parent).

Yet another repeated column in hibernate mapping

Hibernate is giving me the following exception
org.hibernate.MappingException: Repeated column in mapping for entity: Pricelist column: ID_OFFER (should be mapped with insert="false" update="false")
but I really cannot find the duplicate reference to ID_OFFER. Here they are the two mapping files involved.
Offer.hbm.xml
<hibernate-mapping>
<class name="Offer" table="OFFERS">
<id name="idOffer" type="java.lang.Long">
<column name="ID_OFFER" not-null="true" precision="10" scale="0"
sql-type="NUMBER" unique="true"/>
<generator class="native">
<param name="sequence">OFFERS_SEQ</param>
</generator>
</id>
<property generated="never" lazy="false" name="name" type="string">
<column name="name" not-null="true" sql-type="VARCHAR2" unique="true"/>
</property>
<set name="pricelists" sort="unsorted" table="PRICELISTS">
<key not-null="true">
<column name="ID_OFFER" not-null="true" precision="10" scale="0" sql-type="NUMBER"/>
</key>
<one-to-many class="Pricelist"/>
</set>
</class>
</hibernate-mapping>
Pricelist.hbm.xml
<hibernate-mapping>
<class name="Pricelist" table="PRICELISTS">
<id name="idPricelist" type="java.lang.Long">
<column name="ID_PRICELIST" not-null="true" precision="10" scale="0" sql-type="NUMBER"/>
<generator class="native">
<param name="sequence">PRICELISTS_SEQ</param>
</generator>
</id>
<property name="name" type="string">
<column length="255" name="NAME" not-null="true" sql-type="VARCHAR2"/>
</property>
<property name="versionMajor" type="integer">
<column name="VERSION_MAJOR" not-null="true" precision="5" scale="0" sql-type="NUMBER"/>
</property>
<property name="versionMinor" type="integer">
<column name="VERSION_MINOR" not-null="true" precision="5" scale="0" sql-type="NUMBER"/>
</property>
<many-to-one class="Offer" name="offer">
<column name="ID_OFFER" not-null="true" precision="10" scale="0" sql-type="NUMBER"/>
</many-to-one>
<many-to-one class="PricelistStatus" name="status">
<column name="ID_STATUS_PRICELIST" not-null="true" precision="10"
scale="0" sql-type="NUMBER"/>
</many-to-one>
<property name="validFrom" type="calendar">
<column name="INIT_TIMESTAMP" not-null="true" scale="6" sql-type="TIMESTAMP"/>
</property>
<property name="validUntil" type="calendar">
<column name="END_TIMESTAMP" not-null="false" scale="6" sql-type="TIMESTAMP"/>
</property>
</class>
</hibernate-mapping>
I am going crazy. Can anybody see where is it supposed to be duplicated the reference to the column ID_OFFER? Please note: two tables of my schema have a column named like that: OFFERS.ID_OFFER, which is the primary key of the table OFFERS and PRICELIST.ID_OFFER which has a foreign key constraint referencing, obviously, OFFERS.ID_OFFER.
You forgot about map this column as owning side (Offer.hbm.xml file)
<set name="pricelists" sort="unsorted" table="PRICELISTS">
<key not-null="true">
<column name="ID_OFFER" not-null="true" precision="10" scale="0" sql-type="NUMBER"/>
</key>
<one-to-many class="Pricelist"/>
</set>
it should look like (look at inverse="true"):
<set name="pricelists" sort="unsorted" table="PRICELISTS" inverse="true">
<key not-null="true">
<column name="ID_OFFER" not-null="true" precision="10" scale="0" sql-type="NUMBER"/>
</key>
<one-to-many class="Pricelist"/>
</set>
What #zxcf said, actually made the exception disappear, but made another question appear in my mind. Why doesn't the following mapping creates the same problem?
ServiceElement.hbm.xml
<hibernate-mapping>
<class name="ServiceElement" table="SERVICE_ELEMENTS">
<id name="idServiceElement" type="java.lang.Long">
<column name="ID_SERVICE_ELEMENT" not-null="true" precision="10"
scale="0" sql-type="NUMBER" unique="true"/>
<generator class="native">
<param name="sequence">SERVICE_ELEMENTS_SEQ</param>
</generator>
</id>
<set name="prices" table="PRICES">
<key>
<column name="ID_SERVICE_ELEMENT" not-null="true" precision="10"
scale="0" sql-type="NUMBER"/>
</key>
<one-to-many class="Price"/>
</set>
</class>
</hibernate-mapping>
Price.hbm.xml
<hibernate-mapping>
<class name="Price" table="PRICES">
<id name="idPrice" type="java.lang.Long">
<column name="ID_PRICE" not-null="true" precision="10" scale="0"
sql-type="NUMBER" unique="true"/>
<generator class="native">
<param name="sequence">PRICES_SEQ</param>
</generator>
</id>
<many-to-one class="ServiceElement" name="serviceElement">
<column name="ID_SERVICE_ELEMENT" not-null="true" precision="10"
scale="0" sql-type="NUMBER"/>
</many-to-one>
</class>
</hibernate-mapping>
Isn't it the exact same mapping? But it does not throw any exception. Here they go the DDLs:
CREATE TABLE "CE_PRICELIST"."OFFERS"
( "ID_OFFER" NUMBER(10,0),
"NAME" VARCHAR2(255 CHAR));
CREATE UNIQUE INDEX "CE_PRICELIST"."OFFERS_PK" ON "CE_PRICELIST"."OFFERS" ("ID_OFFER");
ALTER TABLE "CE_PRICELIST"."OFFERS" ADD CONSTRAINT "OFFERS_PK" PRIMARY KEY ("ID_OFFER");
CREATE TABLE "CE_PRICELIST"."PRICELISTS"
( "ID_PRICELIST" NUMBER(10,0),
"ID_OFFER" NUMBER(10,0));
CREATE UNIQUE INDEX "CE_PRICELIST"."PRICELISTS_PK" ON "CE_PRICELIST"."PRICELISTS" ("ID_PRICELIST");
ALTER TABLE "CE_PRICELIST"."PRICELISTS" ADD CONSTRAINT "PRICELISTS_PK" PRIMARY KEY ("ID_PRICELIST");
ALTER TABLE "CE_PRICELIST"."PRICELISTS" ADD CONSTRAINT "PRICELISTS_OFFER_ID_FK" FOREIGN KEY ("ID_OFFER") REFERENCES "CE_PRICELIST"."OFFERS" ("ID_OFFER") ENABLE;
CREATE TABLE "CE_PRICELIST"."SERVICE_ELEMENTS"
( "ID_SERVICE_ELEMENT" NUMBER(10,0));
CREATE UNIQUE INDEX "CE_PRICELIST"."SERVICE_ELEMENTS_PK" ON "CE_PRICELIST"."SERVICE_ELEMENTS" ("ID_SERVICE_ELEMENT");
ALTER TABLE "CE_PRICELIST"."SERVICE_ELEMENTS" ADD CONSTRAINT "SERVICE_ELEMENTS_PK" PRIMARY KEY ("ID_SERVICE_ELEMENT");
CREATE TABLE "CE_PRICELIST"."PRICES"
( "ID_PRICE" NUMBER(10,0),
"ID_SERVICE_ELEMENT" NUMBER(10,0));
CREATE UNIQUE INDEX "CE_PRICELIST"."PRICES_PK" ON "CE_PRICELIST"."PRICES" ("ID_PRICE");
ALTER TABLE "CE_PRICELIST"."PRICES" ADD CONSTRAINT "PRICES_SERVICE_ELEMENT_ID_FK" FOREIGN KEY ("ID_SERVICE_ELEMENT")
REFERENCES "CE_PRICELIST"."SERVICE_ELEMENTS" ("ID_SERVICE_ELEMENT") ENABLE;
OFFERS has a PK on ID_OFFER, which is referenced by PRICELISTS.ID_OFFER; Offer has a Set< Pricelist >;
SERVICE_ELEMENTS has a PK on ID_SERVICE_ELEMENT, which is referenced by PRICES.ID_SERVICE_ELEMENT; ServiceElement has a Set< Price >;
So why is the inverse attribute needed in one case and not in another one?

Hibernate order-by removing rows

I have a one-to-Many Set defined in my mapping file, and when I use the order-by property the data in the Set will be missing rows depending on what property I use to order.
<hibernate-mapping>
<class name="domain.StudentUser" table="student_user" >
....
<set name="studentCourseses" inverse="true" order-by="import_date ASC">
<key>
<column name="student_userid" length="15" not-null="true" />
</key>
<one-to-many class="domain.StudentCourses" />
</set>
</hibernate-mapping>
public StudentUser findById(java.lang.String id) {
log.debug("getting StudentUser instance with id: " + id);
try {
StudentUser instance = (StudentUser) getSession().get(
"domain.StudentUser", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
Here i use import_date, but this table has about 15 properties and certain properties will cause rows to be missing from the Set while others don't. It doesn't seem to be data-type specific as I have the issue with a String property but then another String property will work fine and all data will be there. It is always the same rows that are missing no matter the sorting property used, so its not random rows.
The majority of the student_user have data missing, but not all. The rows that end up missing have nothing abnormal about them, meaning no NULL's or anything like that.
As of this point, i just removed the order-by attribute so I can get my app working property, but I still need to know why these issues are happening. So far I have not noticed this behavior in any of the other Set's that i use the order-by attribute with, just this one.
I am using Hibernate 3.5.3 and in case it's helpful, here is the mapping file for the StudentCourses table
<hibernate-mapping>
<class name="domain.StudentCourses" table="student_courses" >
<id name="id" type="integer">
<column name="id" />
<generator class="native" />
</id>
<many-to-one name="classLevel" class="domain.ClassLevel" fetch="select">
<column name="class_level_code" length="2" not-null="true" />
</many-to-one>
<many-to-one name="academicTerm" class="domain.AcademicTerm" fetch="select">
<column name="academic_term_id" not-null="true" />
</many-to-one>
<many-to-one name="studentUser" class="domain.StudentUser" fetch="select">
<column name="student_userid" length="15" not-null="true" />
</many-to-one>
<property name="academicYear" type="integer">
<column name="academic_year" not-null="true" />
</property>
<property name="term" type="string">
<column name="term" length="8" not-null="true" />
</property>
<property name="title" type="string">
<column name="title" length="64" not-null="true" />
</property>
<property name="prefix" type="string">
<column name="prefix" length="8" not-null="true" />
</property>
<property name="courseNum" type="string">
<column name="course_num" length="8" not-null="true" />
</property>
<property name="suffix" type="string">
<column name="suffix" length="8" />
</property>
<property name="sectionNum" type="string">
<column name="section_num" length="8" />
</property>
<property name="units" type="double">
<column name="units" precision="4" not-null="true" unique="true" />
</property>
<property name="letterGrade" type="string">
<column name="letter_grade" length="6" not-null="true" />
</property>
<property name="qtrGpa" type="double">
<column name="qtr_gpa" precision="4" scale="3" not-null="true" />
</property>
<property name="cumGpa" type="double">
<column name="cum_gpa" precision="4" scale="3" not-null="true" />
</property>
<property name="importDate" type="timestamp">
<column name="import_date" length="19" />
</property>
<property name="sourceFileName" type="string">
<column name="source_file_name" length="128" />
</property>
<property name="timeStamp" type="timestamp">
<column name="time_stamp" length="19" not-null="true">
<comment>on update CURRENT_TIMESTAMP</comment>
</column>
</property>
</class>
Update (More Info):
If i directly query the StudentCourses table (CORRECT) vs getting the StudentCourses data from the StudentUser mapping set (INCORRECT) gives me different results, they should match
for(StudentCourses course : getStudentService().retrieveStudentByID("861043440").getStudentCourseses()) { //MISSING DATA
System.out.println(course +" - "+course.getTerm());
}
for(StudentCourses course : (List<StudentCourses>)getStudentService().getStudentCoursesDAO().findByProperty("studentUser.studentUserid", "861043440")) { //ALL DATA CORRECT
System.out.println(course +" - "+course.getTerm());
}
Turns out it had nothing to do with sorting, as adjusting the sorting only fixed the issue for some but not all. The problem was that I had overriden the hashCode method of the StudentCourses object and it was causing collisions when the Set was being populated from the StudentUser object. I fixed this and everything is good now.

one to many relation with column other than Id (Primary Key)

I am trying to map two tables using hibernate one-to-many mapping. But, always it is mapping with the wrong column. Please any body help me on this.
Level4_Master [level_id (PK/Auto Increament), company_id, level_name, next_level_id, ts]
Level3_Master [level_id (PK/Auto Increament), prv_level_id, level_name, next_level_id, ts]
Above are the two tables I am using for the mapping. Here, I wanted to map column next_level_id of Level4_Master with column prv_level_id of Level3_Master. But, hibernate always mapping the column prv_level_id with level_id of Level4_Master as FK. My mapping files are:
<hibernate-mapping>
<class name="com.pojo.Level4" table="Level4_Master">
<id name="levelId" type="java.lang.Integer">
<column name="level_id" />
<generator class="increment" />
</id>
<property name="companyId" >
<column name="company_id" length="10" not-null="true" unique="true" />
</property>
<property name="levelName">
<column name="level_name" length="20" not-null="true" unique="true" />
</property>
<property name="nextLevelId" type="java.lang.Integer">
<column name="next_level_id" />
</property>
<set name="levelList" table="Level3_Master" inverse="true" lazy="true" fetch="select">
<key>
<column name="prv_level_id" not-null="true" />
</key>
<one-to-many class="com.pojo.Level3" />
</set>
</class>
</hibernate-mapping>
and
<hibernate-mapping>
<class name="com.pojo.Level3" table="Level3_Master">
<id name="levelId" type="java.lang.Integer">
<column name="level_id" />
<generator class="increment" />
</id>
<property name="prvLevelId" >
<column name="prv_level_id" length="10" not-null="true" unique="true" />
</property>
<property name="levelName">
<column name="level_name" length="20" not-null="true" unique="true" />
</property>
<property name="nextLevelId" type="java.lang.Integer">
<column name="next_level_id" />
</property>
<set name="levelList" table="Level2_Master" inverse="true" lazy="true" fetch="select">
<key>
<column name="prv_level_id" not-null="true" />
</key>
<one-to-many class="com.pojo.Level2" />
</set>
</class>
</hibernate-mapping>
and my pojo classes are like
class Level4{
private int levelId;
private int companyId;
private String levelName;
private int nextLevelId;
private Set<Level3> levelList = new HashSet<Level3>(0);
private Timestamp ts;
//getter n setter
}
class Level3{
private int levelId;
private int prvLevelId;
private String levelName;
private int nextLevelId;
private Set<Level2> levelList = new HashSet<Level2>(0);
private Timestamp ts;
//getter n setter
}
You need to use property-ref attribute with the property name. The property must add unique="true" in the property mapping.
Example -
<hibernate-mapping><class name="com.pojo.Level4" table="Level4_Master">
<id name="levelId" type="java.lang.Integer">
<column name="level_id" />
<generator class="increment" />
</id>
<property name="companyId" >
<column name="company_id" length="10" not-null="true" unique="true" />
</property>
<property name="levelName">
<column name="level_name" length="20" not-null="true" unique="true" />
</property>
<property name="nextLevelId" type="java.lang.Integer" unique="true">
<column name="next_level_id" />
</property>
<set name="levelList" table="Level3_Master" inverse="true" lazy="true" fetch="select">
<key>
<column name="prv_level_id" not-null="true" property-ref="nextLevelId"/>
</key>
<one-to-many class="com.pojo.Level3" />
</set>

org.hibernate.MappingException: Association references unmapped class

The configuration for User class :
<class name="User" table="users" lazy="false">
<id name="id" column="id">
<generator class="native"/>
</id>
<property name="type" column="type"/>
<many-to-one name="parent" column="parent"/>
<property name="loginName" column="login_name" unique="true" not-null="true" index="idx_users_login_name" length="50"/>
<property name="name" column="name" length="50"/>
<property name="password" column="password"/>
<property name="email" column="email" length="50"/>
<property name="locale" column="locale" length="20"/>
<property name="locked" column="locked"/>
<many-to-one name="metadata" column="metadata_id"/>
<set name="userSpaceRoles" cascade="all" inverse="true" lazy="false">
<key column="user_id"/>
<one-to-many class="UserSpaceRole"/>
</set>
</class>
and for the class MeetingItem is:
<class name="MeetingItem" table="meeting_item">
<id name="id" column="meeting_item_id" type="long">
<generator class="native"/>
</id>
<property name="summary" column="summary" type="string"/>
<property name="detail" column="detail" type="string"/>
<many-to-one name="space" column="space_id"/>
<property name="date" column="date" type="date"/>
<list name="users" cascade="all" lazy="false">
<key column="meeting_item_id"/>
<index column="idx"/>
<one-to-many class="User"/>
</list>
</class>
The problem is I am getting the exception:
org.hibernate.MappingException: Association references unmapped class: info.domain.User
at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2380)
at org.hibernate.cfg.HbmBinder.bindListSecondPass(HbmBinder.java:2231)
at org.hibernate.cfg.HbmBinder$ListSecondPass.secondPass(HbmBinder.java:2729)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)
at org.hibernate.cfg.Configuration.generateSchemaUpdateScript(Configuration.java:936)
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:140)
The mapping of the list is creating the problem. What I am doing wrong?
Edit:
This two configuration resides in different file, if these two are placed in same xml then the problem is not occurring.
please add a reference to the mapping file (which maps info.domain.User) into hibernate.cfg.xml.
Please add class level annotations to register the class as a Spring bean, i.e #Entity in this case since you are not using xml configuration.

Categories