-->
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.  [ 4 posts ] 
Author Message
 Post subject: Read the value of a property length from mapping
PostPosted: Thu Aug 30, 2007 12:23 pm 
Newbie

Joined: Thu Nov 23, 2006 12:18 pm
Posts: 7
Hi.

I want to acces the value of my properties length from the mapping file to implement some prevalidation before persist my entities.
The goal is to check input length before a call to save(...) or update(...) to avoid a Hibernate exception and give to the web app the max length for input fields.

I try to have a look on the ClassMetadata but i couldn't find a way to get the length attribute value.

Is there a way to do this ?

Thanks
Christophe.


Top
 Profile  
 
 Post subject: Re: Read the value of a property length from mapping
PostPosted: Fri Aug 31, 2007 5:25 pm 
Beginner
Beginner

Joined: Tue Oct 10, 2006 3:23 am
Posts: 33
Code:
PersistentClass pc = conf.getClassMapping(classz.getName());
         // pc.getTable().

         Property prop = pc.getProperty("myproperty");
         // log.debug(prop.getName());
         Column c = (Column) prop.getValue().getColumnIterator().next();


Column than has a length field.

* rate if this helps *


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 03, 2007 11:13 am 
Newbie

Joined: Thu Nov 23, 2006 12:18 pm
Posts: 7
I found the way to get this value thru the Configuration object...

But i'm usign Hibernate thru jboss .har packaging, so i'm not able to acces the Configuration object as it is created by the Hibernate MBean and not available anymore after the creation of the SessionFactory.

So i'm still stunk.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 04, 2007 3:26 pm 
Beginner
Beginner

Joined: Tue Oct 10, 2006 3:23 am
Posts: 33
cspada wrote:
I found the way to get this value thru the Configuration object...


Than you should rate :)

Doesn't getSession().getSessionFactory().getClassMetadata(persistentClass)

provide a hook into the Hib persistentClass?? Just guessing here though.


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