People, please help me.
I have the following Oracle DataBase Model
and I need map it to this Java Class Model
I tried to map as follow:
Code:
<class name="Company" table="E_COMPANY">
<id name="id" column="COMPANY_ID" type="long" />
<property name="legalName" type="string" column="LEGALNAME"/>
<property name="peopleSet" type="long" column="people_set"/>
<component name="dataGeneral" class="GeneralData">
<property name="setInterlocutors" type="long" column="interlocutors"/>
<property name="setContacts" type="long" column="contacts"/>
<property name="type" type="long" column="type"/>
<property name="active" type="true_false" column="active"/>
<!-- From joined table -->
<property name="category" type="long" column="COMPANYCATEGORY"/>
<property name="vip" type="true_false" column="B_VIP"/>
</component>
<join table="E_COMPANY_CL">
<key column="COMPANY_ID"/>
</join>
</class>
But Hibernate doesn't recognize the columns coming from the joined table
Quote:
Hibernate: SELECT company0_.COMPANY_ID AS COMPANY1_13_0_, company0_.LEGALNAME AS LEGALNA2_13_0_, company0_.PEOPLE_SET AS PEOPLE3_13_0_, company0_.INTERLOCUTORS AS INTERLO4_13_0_, company0_.CONTACTS AS CONTACS5_13_0_, company0_.TYPE AS TYPE6_13_0_, company0_.ACTIVE AS ACTIVE7_13_0_, company0_.COMPANYCATEGORY AS COMPANY8_13_0_, company0_.B_VIP AS B9_13_0_ FROM E_COMPANY company0_ INNER JOIN E_COMPANY_CL company0_1_ ON company0_.COMPANY_ID =company0_1_.COMPANY_ID WHERE company0_.COMPANY_ID=?
14:29:33,593 TRACE BasicBinder:82 - binding parameter [1] as [BIGINT] - 1007
14:29:33,875 WARN JDBCExceptionReporter:233 - SQL Error: 904, SQLState: 42000
14:29:33,875 ERROR JDBCExceptionReporter:234 - ORA-00904: "COMPANYCOR0_"."COMPANYCATEGORY": invalid identifier
14:29:33,875 INFO DefaultLoadEventListener:160 - Error performing load command
org.hibernate.exception.SQLGrammarException: could not load an entity: [Company#1007]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
The component can't be mapped in a different context, because it throws a
org.hibernate.MappingException: Duplicate property mapping...I need to map these models just like they are, because I'm in a migration project, and I should not do any changes to existing models.
Any suggestion is welcome.PD
SORRY FOR MY BAD ENGLISH, I USE A TRANSLATOR TO TRIED EXPLAIN ME IN THIS FORUM.