-->
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.  [ 6 posts ] 
Author Message
 Post subject: Timestamp mixed type with Middlegen R3
PostPosted: Thu Nov 20, 2003 11:50 am 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
I have columns that are type TIMESTAMP.
When I generate the mapping files with R3, they have type "java.sql.Timestamp" and when I generate the classes with "java net.sf.hibernate.tool.hbm2java.CodeGenerator ...", the class variables have type "java.util.Date". Why is this?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 10:13 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
From wht you are saying hbm2java is not correct so its not a Middlegen issue as such. How about you provide small snipit of code fragments so we can verify if this is issue. Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2003 5:00 am 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
david wrote:
From wht you are saying hbm2java is not correct so its not a Middlegen issue as such. How about you provide small snipit of code fragments so we can verify if this is issue. Thanks.


---------
Tools:
---------

Hibernate 2.0.3
Middlegen R3
hibernate-extensions 2.0

----------------------------------------
Mapping file (generated with R3):
----------------------------------------

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping>
<!--
Created by Middlegen Hibernate plugin

http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->

<class
name="pt.ArmazemMp"
table="armazem_mp"
>

<id
name="mpLoteFk"
type="long"
column="mp_lote_fk"
>
<generator class="increment" />
</id>

<property
name="localizacao"
type="java.lang.String"
column="localizacao"
length="10"
/>
<property
name="userId"
type="java.lang.String"
column="user_id"
not-null="true"
length="10"
/>
<property
name="dtHr"
type="java.sql.Timestamp"
column="dt_hr"
not-null="true"
length="8"
/>

<!-- associations -->
<!-- bi-directional one-to-one association to MpLote -->
<one-to-one
name="mpLote"
class="pt.MpLote"
outer-join="auto"
/>

</class>
</hibernate-mapping>

-----------------------------------------------
Java classe (generated with hbm2java):
-----------------------------------------------

package pt;

import java.io.Serializable;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

/** @author Hibernate CodeGenerator */
public class ArmazemMp implements Serializable {

/** identifier field */
private Long mpLoteFk;

/** nullable persistent field */
private String localizacao;

/** persistent field */
private String userId;

/** persistent field */
private java.util.Date dtHr;

/** nullable persistent field */
private pt.comseal.arsol.vo.MpLote mpLote;

/** full constructor */
public ArmazemMp(java.lang.String localizacao, java.lang.String userId, java.util.Date dtHr, pt.comseal.arsol.vo.MpLote mpLote) {
this.localizacao = localizacao;
this.userId = userId;
this.dtHr = dtHr;
this.mpLote = mpLote;
}

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

/** minimal constructor */
public ArmazemMp(java.lang.String userId, java.util.Date dtHr) {
this.userId = userId;
this.dtHr = dtHr;
}

public java.lang.Long getMpLoteFk() {
return this.mpLoteFk;
}

public void setMpLoteFk(java.lang.Long mpLoteFk) {
this.mpLoteFk = mpLoteFk;
}

public java.lang.String getLocalizacao() {
return this.localizacao;
}

public void setLocalizacao(java.lang.String localizacao) {
this.localizacao = localizacao;
}

public java.lang.String getUserId() {
return this.userId;
}

public void setUserId(java.lang.String userId) {
this.userId = userId;
}

public java.util.Date getDtHr() {
return this.dtHr;
}

public void setDtHr(java.util.Date dtHr) {
this.dtHr = dtHr;
}

public pt.comseal.arsol.vo.MpLote getMpLote() {
return this.mpLote;
}

public void setMpLote(pt.comseal.arsol.vo.MpLote mpLote) {
this.mpLote = mpLote;
}

( ... )
}

----------------
Conclusions:
----------------

As you can see, the property "dtHr" is type "java.sql.Timestamp" in the mapping file and in the class it has type "java.util.Date".


Top
 Profile  
 
 Post subject: Same Problem
PostPosted: Wed Jan 14, 2004 2:16 pm 
Newbie

Joined: Wed Jan 14, 2004 2:14 pm
Posts: 1
I am experiencing the exact same problem. It seems hbm2java reads Timestamp from the .HBM.XML file and generates the .java file with a Date.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2004 10:26 pm 
Newbie

Joined: Fri Feb 13, 2004 10:22 pm
Posts: 1
I'm having this problem as well. I don't think it's related to the schema-generation. I've scanned the source code for the hbm2java, but was unable to find what I did wrong. Any help would be appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 14, 2004 10:30 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Ummm. Guys. Timestamp inherits Date. This is correct functionality.


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