I have my MySQL DB Schema and I use Hibernate Reverse Engineering to create an annotated domain object (.java). Although the file is generated correctly, it somehow skips the Generator annotation for the ID field.
Below is my hibernate.reveng.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE
hibernate-reverse-engineering PUBLIC
"-//Hibernate/Hibernate Reverse
Engineering DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd"
<hibernate-reverse-engineering>
<table-filter match-name="products" match-catalog="test"></table-filter>
<table catalog="test" name="products">
<primary-key>
<generator class="native"></generator>
<key-column name="product_id"property="product_id" />
</primary-key>
</table>
</hibernate-reverse-engineering>
and the generated class file (Products.java):
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "products", catalog = "test")
public class Products implements java.io.Serializable {
private String productId;
private String productName;
public Products() {
}
public Products(String productId) {
this.productId = productId;
}
public Products(String productId, String productName) {
this.productId = productId;
this.productName = productName;
}
@Id
@Column(name = "product_id", unique = true, nullable = false, length = 50)
public String getProductId() {
return this.productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
@Column(name = "product_name", length = 200)
public String getProductName() {
return this.productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
}
Is there something missing in my hibernate.reveng.xml or hibernation that doesn't generate annotations for the "generator"?
mayur source
share