File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes hbm2java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hbm2java" Watch "hbm2java" New topic
Author

hbm2java

Sagar Kale
Ranch Hand

Joined: May 02, 2008
Posts: 188
I tried to build POJOs with hbm2java of hibernate tools. It works perfect except in the following situation

Case 1) Works OK

<?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 package="com.test.web">
<class name="Test100" table="test100">
<id name="testId" column="testId" type="integer">
<generator class="native"></generator>
</id>

<property name="middleName" column="middleName" type="string" unique="true" ></property>
</class>


</hibernate-mapping>




package com.test.web;
// Generated Dec 4, 2008 8:50:04 PM by Hibernate Tools 3.2.0.b9



/**
* Test100 generated by hbm2java
*/
public class Test100 implements java.io.Serializable {


private Integer testId;
private String middleName;

public Test100() {
}

public Test100(String middleName) {
this.middleName = middleName;
}

public Integer getTestId() {
return this.testId;
}

public void setTestId(Integer testId) {
this.testId = testId;
}
public String getMiddleName() {
return this.middleName;
}

public void setMiddleName(String middleName) {
this.middleName = middleName;
}




}


Works ok.



Now case 2 )



Now I added <properties > ........ </properties>.




<?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 package="com.test.web">
<class name="Test100" table="test100">
<id name="testId" column="testId" type="integer">
<generator class="native"></generator>
</id>
<properties name="testUnique" unique="true" update="false">
<property name="firstName" column="firstName" type="string"></property>
<property name="lastName" column="lastName" type="string"></property>
</properties>

<property name="middleName" column="middleName" type="string" unique="true" ></property>
</class>


</hibernate-mapping>



package com.test.web;
// Generated Dec 4, 2008 8:53:43 PM by Hibernate Tools 3.2.0.b9



/**
* Test100 generated by hbm2java
*/
public class Test100 implements java.io.Serializable {


private String firstName;
private String lastName;

public Test100() {
}

public Test100(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}

public String getFirstName() {
return this.firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return this.lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}




}


In this case, it does not add properties testId, and middleName in generated POJO. Did I made any mistake or it is bug

[ December 04, 2008: Message edited by: Sagar Kale ]

[ December 04, 2008: Message edited by: Sagar Kale ]
[ December 04, 2008: Message edited by: Sagar Kale ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: hbm2java