-->
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.  [ 1 post ] 
Author Message
 Post subject: toString in Id classes
PostPosted: Wed Feb 29, 2012 9:20 am 
Senior
Senior

Joined: Fri May 08, 2009 12:27 pm
Posts: 168
Hi all,

I have many tables with composite keys, which generate Id classes during reveng.
I'd like to see reveng generate toString() on these Id classes. (NOT on the entity classes themselves, that would eventually pull in the entire database and then generate infinite output due to circular references between Pojos.)

The Id classes do get equals() and hashCode(), but no toString().
The PojoToString.ftl template file checks a pojo.needsToString() property, but I don't know how to trigger that property at the right times.

I could use <meta attribute="use-in-tostring">true</meta> on all id attributes in all tables, but that would be a lot of XML coding.
Or maybe add the meta in the reveng strategy class (I have one anyway). Not sure where that should be added though.
Either way, I suspect the generated toString might go into the entity class, and I don't want it there.

Use case
I'm currently hunting a bug that says things like
Code:
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [class.path.Entity#class.path.EntityId@599b1a9e]
The part after the # is effectively generated from somePojo.getId().toString(), and I want a toString that mentions the field values, Object#toString() gives me a rather useless JVM id.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.