-->
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: PropertyAccessor or UserType ?
PostPosted: Sat Dec 10, 2005 5:37 am 
Newbie

Joined: Fri Nov 12, 2004 1:40 am
Posts: 7
i dont know whether to use PropertyAccessor or UserType for the following problem :

i have a "code" property in my db. i want to insert formatted text in it.
different formats should come from an xml file.

for example i need to insert "CurrentDate / Financial Year / auto number"
into the code field.

it should look something like "2005-12-8/05/1"
and the next insert will be "2005-12-8/05/2"

another user may choose another format from xml. somting like:
"currentDate / INV / autonumber"

which will insert into db as : "2005-12-8/INV/1" and so on.

now i dont know whether i need to implement a propertyaccessor or i need to define a new usertype.

thax


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 10, 2005 8:25 am 
Newbie

Joined: Fri Nov 12, 2004 1:40 am
Posts: 7
or maybe i should change my question as follows :

is there a generator for property ?
i know it exists for id.
thax


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 10, 2005 9:55 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
usertype or db-trigger

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 10, 2005 4:56 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
It must be better to store plain date in database and to format it on client. So you do not need PropertyAccessor or UserType to solve this problem, it doe's not make sence.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 5:57 pm 
Beginner
Beginner

Joined: Wed May 25, 2005 7:49 pm
Posts: 25
If it's a legacy data model, there might not be a way around it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 13, 2005 2:47 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
If this is legacy model then formated text is just a string, is not ? But there are many good reasons not store formated text and it must be a very good reason to break 1 NF rule.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 14, 2005 9:28 am 
Beginner
Beginner

Joined: Wed May 25, 2005 7:49 pm
Posts: 25
You're right in that it's just a string, but a good domain model shouldn't store formatted text, regardless of the persistence layer's representation.

I agree with you about not storing formatted text in the database. Unfortunately, there are a lot of data models out there that were designed by people who had no idea what they were doing.


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.