- This topic has 2 replies, 2 voices, and was last updated 18 years, 8 months ago by Tringle.
-
AuthorPosts
-
TringleMemberDear all:
These days I tried to develope struts and hibernate3 application in Myeclipse4.1.1.I used the wizard to add the hibernate capabilities to the JavaProject and used the Create Hibernate Mapping Item of the DB Brower’s PopupMenu.But I found something special.It generated three java file and one hbm.xml file.The three java file name are: AbstractAssessGrade.java, AssessGrade.java and AssessGradeId.java.The hbm.xml file generated like the following:<hibernate-mapping>
<class name=”com.test.grade.AssessGrade” table=”AssessGrade” schema=”dbo” catalog=”kpi_tg”>
<composite-id name=”id” class=”com.test.grade.AssessGradeId”>
<key-property name=”gradeId” type=”string”>
<column name=”gradeId” length=”32″ />
</key-property>
<key-property name=”gradeName” type=”string”>
<column name=”gradeName” length=”50″ />
</key-property>
<key-property name=”maxGrade” type=”double”>
<column name=”maxGrade” precision=”18″ scale=”3″ />
</key-property>
<key-property name=”minGrade” type=”double”>
<column name=”minGrade” precision=”18″ scale=”3″ />
</key-property>
<key-property name=”limitCount” type=”integer”>
<column name=”limitCount” />
</key-property>
<key-property name=”createTime” type=”timestamp”>
<column name=”createTime” length=”23″ />
</key-property>
</composite-id>
</class>
</hibernate-mapping>❓ What’s the “composite-id” element and the AssessGradeId.java?
This hbm.xml file’s structure is not like those examples in the Hibernate3.1.2.zip.
❓ Can anyone tell me how the three java file work?
In the Hibernate3.1.2.zip’s examples there are onle one POJO and hbm.xml file .
Haris PecoMemberTringle,
MyEclipse use hibernate 3.0.5 version, but it isn’t important for your problem
You can suppress generate Abstract class in Page 1 wizard (un-check ‘Create Abstract class’).Intention for abstract class is change and regenerate mappings (regenerate doesn’t touch class,only abstract class), but you can suppress this.
Composite Id class is generated when your table have composite PK (primary key with > 1 columns).It is pattern from hibernate (see chapter 8.4 in hibernate documentation).If you have table with simple PK (one column PK) and unchecked ‘Create Abstract class’ you will got one POJO and one hbm.xml.
However, you can work with composite ID (with/without Abstract class) – it;s same like your one POJO/One hbm.xml examplesIf you have problem still, then send us mappings and your usage snippet (test case or what ever)
Best
TringleMemberOh,I see. Thanks
-
AuthorPosts