-->
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.  [ 7 posts ] 
Author Message
 Post subject: hbm2java toString() generetor
PostPosted: Sun Jan 16, 2005 5:57 pm 
Beginner
Beginner

Joined: Sat Jan 15, 2005 4:50 am
Posts: 23
Hi!

I asked this question in Hibernate Users a few days ago, and haven't got a reply. Maybe it's a better place place for it.

So, i put this metadata: <meta attribute="use-in-tostring">true</meta> on a property, in order to
include just this property in the container class toString().

For example, if this property's value is "A", i want it's class toString() to write this: A

My problem is that it writes something like this: package.Class@1c8ef56[id=foo,property=foo]

could you tell me why? thanks for help.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 16, 2005 7:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
check the code generated and you will see why.

It uses commons stringbuilder in the h2.1 version....in the future it won't..

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 16, 2005 7:31 pm 
Beginner
Beginner

Joined: Sat Jan 15, 2005 4:50 am
Posts: 23
max wrote:
check the code generated and you will see why.

It uses commons stringbuilder in the h2.1 version....in the future it won't..


so, it's a problem with commons.lang.builder.ToStringBuilder

are there any solution?

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 17, 2005 4:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
extend BasicRenderer and make it write the toString you want.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 17, 2005 9:26 am 
Beginner
Beginner

Joined: Sat Jan 15, 2005 4:50 am
Posts: 23
max wrote:
extend BasicRenderer and make it write the toString you want.


Could you explain how to do this? I have read the documentation, but still have no idea.

here is my config file:

<codegen>
<generate renderer="net.sf.hibernate.tool.hbm2java.BasicRenderer"/>
<generate package="org.hgpm.model.entity.finders" suffix="Finder" renderer="net.sf.hibernate.tool.hbm2java.FinderRenderer"/>
</codegen>

thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 17, 2005 9:28 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
extend BasicRenderer and use it instead of BasicRenderer.

Code:
<generate renderer="org.whatever.YourOwnBasicRenderer"/>


remember to place your own basic renderer in the classpath of hbm2java so it can find it.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 11:08 am 
Beginner
Beginner

Joined: Sat Jan 15, 2005 4:50 am
Posts: 23
max wrote:
extend BasicRenderer and use it instead of BasicRenderer.

Code:
<generate renderer="org.whatever.YourOwnBasicRenderer"/>


remember to place your own basic renderer in the classpath of hbm2java so it can find it.


thanks max, it works now.
in the future, i hope there will be a simpler solution to this problem.


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