-->
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: hibernate 3, hbm2java and native int properties
PostPosted: Fri Sep 23, 2005 10:59 am 
Newbie

Joined: Tue Aug 17, 2004 6:29 pm
Posts: 2
I am using hbm2java to generate pojos, and have been moving over to hibernate 3. However, in the mapping below, I expect the field sortOrder to be generated as an int. Instead it is being generated as an Integer. Things worked fine in 2.x. How do I make it work in 3.0.x? (Mapping and generated pojo included).

Thanks

eotoole


Hibernate version:
3.0.5

Mapping documents:
<?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.cystemstech.ost.vo">

<class name="SiteMapItemVO" table="site_map_item">
<id name="id"
column="id"
type="long">
<generator class="sequence">
<param name="sequence">seq_site_map_item</param>
</generator>
</id>
<property name="path" column="path" type="string" />
<property name="description" column="description" type="string" />
<property name="sortOrder" column="sort_order" type="int" not-null="true" />
<property name="actionURL" column="action_url" type="string" />
<property name="imageOn" column="image_on" type="string" />
<property name="imageOff" column="image_off" type="string" />
<property name="type" column="type" type="string" />
<property name="layoutName" column="layout_name" type="string" />
<!-- bag name="roles" table="site_map_item_role_map" lazy="true">
<key column="site_map_item_id" />
<many-to-many column="role_id" class="RoleVO" />
</bag -->
</class>

</hibernate-mapping>

The generated POJO:

package com.cystemstech.ost.vo;

import java.util.*;




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

// Fields

private Long id;
private String path;
private String description;
private Integer sortOrder;
private String actionURL;
private String imageOn;
private String imageOff;
private String type;
private String layoutName;


// Constructors

/** default constructor */
public SiteMapItemVO() {
}

/** constructor with id */
public SiteMapItemVO(Long id) {
this.id = id;
}




// Property accessors

/**
*
*/
public Long getId() {
return this.id;
}

public void setId(Long id) {
this.id = id;
}

/**
*
*/
public String getPath() {
return this.path;
}

public void setPath(String path) {
this.path = path;
}

/**
*
*/
public String getDescription() {
return this.description;
}

public void setDescription(String description) {
this.description = description;
}

/**
*
*/
public Integer getSortOrder() {
return this.sortOrder;
}

public void setSortOrder(Integer sortOrder) {
this.sortOrder = sortOrder;
}

/**
*
*/
public String getActionURL() {
return this.actionURL;
}

public void setActionURL(String actionURL) {
this.actionURL = actionURL;
}

/**
*
*/
public String getImageOn() {
return this.imageOn;
}

public void setImageOn(String imageOn) {
this.imageOn = imageOn;
}

/**
*
*/
public String getImageOff() {
return this.imageOff;
}

public void setImageOff(String imageOff) {
this.imageOff = imageOff;
}

/**
*
*/
public String getType() {
return this.type;
}

public void setType(String type) {
this.type = type;
}

/**
*
*/
public String getLayoutName() {
return this.layoutName;
}

public void setLayoutName(String layoutName) {
this.layoutName = layoutName;
}




}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 23, 2005 11:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
currently use <meta attribute="property-type" inherit="false">int</meta> to override it.

The h3 tools currently have a consistent rule of using the name returned by the Type.getReturnedClass() which for primitives results in the Object version.

We will probably add an option (or maybe a default) that says "use the type attribute directly when it is primitive (since if it is a usertype it wont be good ;)"

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 23, 2005 12:09 pm 
Newbie

Joined: Tue Aug 17, 2004 6:29 pm
Posts: 2
Thanks, that solves it.

FWIW I think its a great idea to add the default behavior (rather than the option) you mention, since that will ease migration just that little bit more.

Eoin


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.