-->
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.  [ 12 posts ] 
Author Message
 Post subject: net.sf.hibernate.test.DoubleStringType
PostPosted: Wed Feb 25, 2004 7:06 am 
Beginner
Beginner

Joined: Tue Feb 10, 2004 5:48 am
Posts: 20
A reference to net.sf.hibernate.test.DoubleStringType is made in the Hibernate Reference Documentation. Where do I find such class? The package test doesn't seem to exist in the API, and searching google doesn't turn up anything other than the documentation reference. Please help!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 25, 2004 7:12 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You have to write it yourself. That was the point, AFAIK.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: Still doesn't make sense.
PostPosted: Wed Feb 25, 2004 8:02 am 
Beginner
Beginner

Joined: Tue Feb 10, 2004 5:48 am
Posts: 20
It doesn't seem that way to me. They refer to it as if it was already created. In fact, they say "Check out net.sf.hibernate.test.DoubleStringType to see the kind of things that are possible"... Perhaps there is a downloadable sample package?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 25, 2004 9:09 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
In src/net/sf/hibernate/test dir of the distribution

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Thanks
PostPosted: Wed Feb 25, 2004 9:20 am 
Beginner
Beginner

Joined: Tue Feb 10, 2004 5:48 am
Posts: 20
Thanks, I found it, but I only had access to the compiled class, so my search for a .java file failed ;-)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 25, 2004 10:41 am 
Beginner
Beginner

Joined: Tue Jan 27, 2004 2:14 pm
Posts: 40
Location: Atlanta, GA, USA
http://cvs.sourceforge.net/viewcvs.py/hibernate/Hibernate2/src/net/sf/hibernate/test/DoubleStringType.java

Click the download link near the top of the page.


Top
 Profile  
 
 Post subject: Tutorial for creating the type class?
PostPosted: Thu Feb 26, 2004 6:13 am 
Beginner
Beginner

Joined: Tue Feb 10, 2004 5:48 am
Posts: 20
Right, I can now write by hand a hibernate mapping file that maps a single java object to two database columns (because it seems that middlegen can't generate this automatically?). Are there tutorials for writing the actual class file that gets put into the hibernate-2.0.3/build/net/sf/hibernate/type directory (to map an object to 2 database columns)? Any help would be appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2004 6:30 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
http://cvs.sourceforge.net/viewcvs.py/*checkout*/hibernate/Hibernate2/src/net/sf/hibernate/test/DoubleStringType.java?content-type=text%2Fplain&rev=1.6.2.1

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Correct file?
PostPosted: Thu Feb 26, 2004 6:41 am 
Beginner
Beginner

Joined: Tue Feb 10, 2004 5:48 am
Posts: 20
Merci, Emmanuel. I must say, you guys are excellent on your response times! Nice to know there is good support for your "product".

The link you gave me is the file DoubleTypeString.java. Thats great as I wasn't able to get it from the previous reply with the link to CVS. I still of course need help creating the file in my last posting, that goes into the hibernate-2.0.3/build/net/sf/hibernate/type directory. I will also need to write the hibernate java file for the java object:

java object (needs to map to 2 date columns in the DB)
-> hibernate mapping file .hbm.xml
-> hibernate java
-> hibernate class file (hibernate-2.0.3/build/net/sf/hibernate/type)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2004 6:45 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I don't really get you

Code:
<property name="twoStrings" type="net.sf.hibernate.test.DoubleStringType">
    <column name="first_string"/>
    <column name="second_string"/>
</property>


The Hibernate DoubleStringType is the custom type : check the link to find the code.

There is nothing else to do

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Ok
PostPosted: Thu Feb 26, 2004 7:06 am 
Beginner
Beginner

Joined: Tue Feb 10, 2004 5:48 am
Posts: 20
Ok, everything is understood now. Thanks for your help.


Top
 Profile  
 
 Post subject: Sorry
PostPosted: Thu Feb 26, 2004 7:15 am 
Beginner
Beginner

Joined: Tue Feb 10, 2004 5:48 am
Posts: 20
Sorry, thought everything was ok, but its not, as I realised now that because we can't use middlegen, the hibernate java file won't be generated automatically, and then compiled. These "java" files contain basically the database fields, getters and setters and some other methods. An example is below. Do I need to put anything special in my own "java" file to handle the fact that the type maps to 2 db columns?

package com.lbss.framework.persistence.test.data;

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 TypeTest implements Serializable {

/** identifier field */
private Long id;

...

public java.lang.Long getId() {
return this.id;
}

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

...

public String toString() {
return new ToStringBuilder(this)
.append("id", getId())
.toString();
}

public boolean equals(Object other) {
if ( !(other instanceof TypeTest) ) return false;
TypeTest castOther = (TypeTest) other;
return new EqualsBuilder()
.append(this.getId(), castOther.getId())
.isEquals();
}

public int hashCode() {
return new HashCodeBuilder()
.append(getId())
.toHashCode();
}

}


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