-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Columns named 'version'
PostPosted: Mon Aug 18, 2008 1:48 pm 
Newbie

Joined: Mon Aug 18, 2008 7:03 am
Posts: 2
Location: Andover, MA
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;
}




}

_________________
Signs you are a geek:

You find yourself figuring out how to explain a fourth dimensional car to a lay man for purposes of an interesting thought experiment.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 22, 2008 5:00 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
look in the documentation and see how to disable optimstick-lock detection.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Thanks
PostPosted: Mon Aug 25, 2008 7:54 am 
Newbie

Joined: Mon Aug 18, 2008 7:03 am
Posts: 2
Location: Andover, MA
Thanks Max, I must have cleverly jumped over it at least a few times in the doc.

_________________
Signs you are a geek:

You find yourself figuring out how to explain a fourth dimensional car to a lay man for purposes of an interesting thought experiment.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.