-->
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.  [ 3 posts ] 
Author Message
 Post subject: Extend Pojo or using a custom mapping type ?
PostPosted: Fri Oct 08, 2004 4:09 am 
Newbie

Joined: Fri Aug 20, 2004 5:19 am
Posts: 14
Good morning

For a project:
a varchar table column entitled 'description' in the database contains a special token
to specify carriage return,
for example @return@ (customer wishes to not put real carriage return in the database column).

For the interface application views, we need to replace the special tokens @return@ by a carriage return
to display correctly the value extracted from the column table 'description'

We see at least 2 strategies:

- first strategy :

extend the POJO corresponding to the table with column 'description', to modify the accesor method
getDescription(
output = super.getDescription();
replace in string output the @return@ tokens with a viewable value
return output
)

we do not like this strategy because the POJO will be explicitly linked to details about
the database (@return@ token in a column of a table) so less reusable.

- second strategy:

use an hibernate custom mapping type to do the string replacement
when a new POJO is initialised by an insert in the database.

Is the second strategy too exotic for this problem
or should we use an other approach ?

thank you for any advise
F


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 10, 2004 3:30 pm 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
I guess with custom mapping type you mean UserType or CompositeUserType.

We've a legacy Db with all sorts of funny tricks. In order to solve some of this problems, we're using several different (Composite)UserTypes with great success. Very often they allow to solve a problem without having the domain model to worry about it.

IMHO: A UserType is exacty what I would use for your problem.

HTH
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 10, 2004 3:42 pm 
Newbie

Joined: Fri Aug 20, 2004 5:19 am
Posts: 14
thank you Ernst for your advise


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