-->
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.  [ 9 posts ] 
Author Message
 Post subject: BigInteger + XDoclet problem
PostPosted: Mon Jan 05, 2004 12:38 pm 
Regular
Regular

Joined: Fri Nov 21, 2003 10:23 am
Posts: 81
When I change in my domain model type Integer to BigInteger, hibernate xdoclet ant task fail with error : (TemplateEngine.invokeMethod 573 ) Invoking method failed: xdoclet.modules.hibernate.HibernateTagsHandler.ifHasCompositeId, line=107 of template file: jar:file:C:\java\projects\excom2lib\xdoclet-1.2\lib\xdoclet-hibernate-module-1.2.jar!/xdoclet/modules/hibernate/resources/hibernate.xdt


If I use f.e. Long instead of Integer, everything works ok (both cases, Integer and Long).

Can you help me anybody?
Thaks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 05, 2004 1:17 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Please show your class with the XDoclet Tags


Top
 Profile  
 
 Post subject: example of class with hibernate tags that fails
PostPosted: Mon Jan 05, 2004 1:23 pm 
Regular
Regular

Joined: Fri Nov 21, 2003 10:23 am
Posts: 81
package com.domainmodel;

// import packages

import java.math.BigInteger;

/**
* @hibernate.class table="WEEK_NON_WORKING_DAY_TBL"
*/
public class WeekNonWorkingDay implements java.io.Serializable {
public BigInteger weekNonWorkingDayId;
public BigInteger calendarId;
public Calendar calendar;
public BigInteger day;

public void setWeekNonWorkingDayId(BigInteger weekNonWorkingDayId) {
this.weekNonWorkingDayId = weekNonWorkingDayId;
}

/**
* @hibernate.id generator-class="native" length="5"
*/
public BigInteger getWeekNonWorkingDayId() {
return weekNonWorkingDayId;
}

public void setCalendarId(BigInteger calendarId) {
this.calendarId = calendarId;
}

public BigInteger getCalendarId() {
return calendarId;
}

public void setCalendar(Calendar calendar) {
this.calendar = calendar;
}

/**
* @hibernate.many-to-one column="CalendarID" class="com.domainmodel.Calendar"
*/
public Calendar getCalendar() {
return calendar;
}

public void setDay(BigInteger day) {
this.day = day;
}

/**
* @hibernate.property length="1"
*/
public BigInteger getDay() {
return day;
}
public WeekNonWorkingDay() {
super();
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 05, 2004 1:28 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
have you tried setting type="java.lang.BigInteger" in your xdoclet tag. However there currently is no builtin Hibernate type which maps to a BigInteger. Are you sure this works out of the Box? Does it work when storing and loading your BigInteger properties?


Top
 Profile  
 
 Post subject: BigInteger not supported
PostPosted: Mon Jan 05, 2004 2:05 pm 
Regular
Regular

Joined: Fri Nov 21, 2003 10:23 am
Posts: 81
OK, I fixed this error in XDoclet Hibernate in sources (in class HibernateTagsHandler.java), but problem is also in hibernate (as you said). BigInteger is not supported type.

Question for Gavin: Will be java.lang.BigInteger supported in near future?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 05, 2004 2:29 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Use a custom type

_________________
Emmanuel


Top
 Profile  
 
 Post subject: workaround?
PostPosted: Mon Jan 05, 2004 2:56 pm 
Regular
Regular

Joined: Fri Nov 21, 2003 10:23 am
Posts: 81
Emmanuel, I am afraid that custom tag will not work with XDoclet hibernate.id in the same way as BigInteger is.


Now I am trying something like this, but it is still not working:

package com.domainmodel;

// import packages

import java.util.Date;
import java.sql.Time;
import java.math.BigDecimal;
import java.math.BigInteger;

/**
* @hibernate.class table="WEEK_NON_WORKING_DAY_TBL"
*/
public class WeekNonWorkingDay implements java.io.Serializable {
public java.math.BigInteger weekNonWorkingDayId;
public java.math.BigInteger day;

public void setWeekNonWorkingDayId(java.math.BigInteger weekNonWorkingDayId) {
this.weekNonWorkingDayId = weekNonWorkingDayId;
}

/**
* @hibernate.id generator-class="native" type="java.lang.Integer"
*/
public java.math.BigInteger getWeekNonWorkingDayId() {
return weekNonWorkingDayId;
}

public void setDay(java.math.BigInteger day) {
this.day = day;
}

/**
* @hibernate.property type="java.lang.Integer"
*
*/
public java.math.BigInteger getDay() {
return day;
}
public WeekNonWorkingDay() {
super();
}
}


Top
 Profile  
 
 Post subject: Re: workaround?
PostPosted: Mon Jan 05, 2004 4:39 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
pstruhos wrote:
Emmanuel, I am afraid that custom tag will not work with XDoclet hibernate.id in the same way as BigInteger is.

I don't get you. I was pointing 5.2.4. Custom value types.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: solution ->custom type
PostPosted: Wed Jan 07, 2004 4:56 am 
Regular
Regular

Joined: Fri Nov 21, 2003 10:23 am
Posts: 81
With custom type it works:

public class CustomBigInteger implements UserType {
private static final int[] TYPES = {Types.INTEGER};

public CustomBigInteger() {
}

public int[] sqlTypes() {
return TYPES;
}

public Class returnedClass() {
return java.math.BigInteger.class;
}

public boolean equals(Object o, Object o1) throws HibernateException {
if (o == o1) return true;
if (o == null || o1 == null) return false;
return o.equals(((java.math.BigInteger) o1));
}

public Object nullSafeGet(ResultSet resultSet, String[] strings, Object o) throws HibernateException, SQLException {
Object retO = Hibernate.INTEGER.nullSafeGet(resultSet, strings[0]);
Object bd = null;
if (retO != null) {
bd = new java.math.BigInteger(retO.toString());
}
return bd;
}

public void nullSafeSet(PreparedStatement preparedStatement, Object o, int i) throws HibernateException, SQLException {
String s = null;
if (o != null) {
s = o.toString();
}
Integer intg = new Integer(s);
Hibernate.INTEGER.nullSafeSet(preparedStatement, intg, i);
}

public Object deepCopy(Object o) throws HibernateException {
Object oCpy = null;
if (o != null) {
oCpy = new java.math.BigInteger(o.toString());
}
return oCpy;
}

public boolean isMutable() {
return true;
}
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.