Hello all,
I've been having problems with mapping a column named "version". I remember seeing this problem somewhere but have not been able to find it again. When reverse-engineering the database, columns named "version" are mapped to a version element rather than a property. Initially I was getting a casting exception because version elements default to a type of integer. Using reveng.xml I have been able to force a change in the type using 'property="property_name"'; however, it is still in the mapping file as a version element. Though it is now of type string, I still get the class casting exception. Is there any way to force this column to be a property in reveng.xml?
EDIT:
I have found where I have seen this before. The following link is to an old issue where the user was experiencing the same problem. It was the followups in the comments that showed the issue is actually with hibernate tools and columns with the name 'version'.
http://opensource.atlassian.com/project ... e/HHH-3002
Hibernate version: 3.2.6 GA
reveng.xml excerpt:
<table name="MCD" >
<primary-key>
<generator class="sequence">
<param name="sequence">MASTER_SEQ</param>
</generator>
</primary-key>
<column name="VERSION" property="version" type="string" />
</table>
resulting hbm.xml:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Aug 18, 2008 12:19:17 PM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
<class name="com.vicr.mdm.pojos.Mcd" table="MCD">
<id name="mcdId" type="long">
<column name="MCD_ID" precision="22" scale="0" />
<generator class="sequence">
<param name="sequence">MASTER_SEQ</param>
</generator>
</id>
<version name="version" type="string">
<column name="VERSION" length="20" />
</version>
<property name="formType" type="string">
<column name="FORM_TYPE" length="20" />
</property>
<property name="declarationType" type="string">
<column name="DECLARATION_TYPE" length="20" />
</property>
<property name="ipcStandard" type="string">
<column name="IPC_STANDARD" length="20" />
</property>
<set name="responses" inverse="true">
<key>
<column name="MCD_ID" precision="22" scale="0" not-null="true" />
</key>
<one-to-many class="com.vicr.mdm.pojos.Response" />
</set>
<set name="requests" inverse="true">
<key>
<column name="MCD_ID" precision="22" scale="0" not-null="true" />
</key>
<one-to-many class="com.vicr.mdm.pojos.Request" />
</set>
<set name="productIds" inverse="true">
<key>
<column name="MCD_ID" precision="22" scale="0" not-null="true" />
</key>
<one-to-many class="com.vicr.mdm.pojos.ProductId" />
</set>
<set name="pips" inverse="true">
<key>
<column name="MCD_ID" precision="22" scale="0" not-null="true" />
</key>
<one-to-many class="com.vicr.mdm.pojos.Pip" />
</set>
</class>
</hibernate-mapping>
Generated POJO:
package com.vicr.mdm.pojos;
// Generated Aug 18, 2008 12:19:23 PM by Hibernate Tools 3.2.1.GA
import java.util.HashSet;
import java.util.Set;
/**
* Mcd generated by hbm2java
*/
public class Mcd implements java.io.Serializable {
private long mcdId;
private String version;
private String formType;
private String declarationType;
private String ipcStandard;
private Set responses = new HashSet(0);
private Set requests = new HashSet(0);
private Set productIds = new HashSet(0);
private Set pips = new HashSet(0);
public Mcd() {
}
public Mcd(String formType, String declarationType, String ipcStandard, Set responses, Set requests, Set productIds, Set pips) {
this.formType = formType;
this.declarationType = declarationType;
this.ipcStandard = ipcStandard;
this.responses = responses;
this.requests = requests;
this.productIds = productIds;
this.pips = pips;
}
public long getMcdId() {
return this.mcdId;
}
public void setMcdId(long mcdId) {
this.mcdId = mcdId;
}
public String getVersion() {
return this.version;
}
public void setVersion(String version) {
this.version = version;
}
public String getFormType() {
return this.formType;
}
public void setFormType(String formType) {
this.formType = formType;
}
public String getDeclarationType() {
return this.declarationType;
}
public void setDeclarationType(String declarationType) {
this.declarationType = declarationType;
}
public String getIpcStandard() {
return this.ipcStandard;
}
public void setIpcStandard(String ipcStandard) {
this.ipcStandard = ipcStandard;
}
public Set getResponses() {
return this.responses;
}
public void setResponses(Set responses) {
this.responses = responses;
}
public Set getRequests() {
return this.requests;
}
public void setRequests(Set requests) {
this.requests = requests;
}
public Set getProductIds() {
return this.productIds;
}
public void setProductIds(Set productIds) {
this.productIds = productIds;
}
public Set getPips() {
return this.pips;
}
public void setPips(Set pips) {
this.pips = pips;
}
}