-->
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: How to get maxlenght of string property using API
PostPosted: Wed Jan 12, 2005 10:31 am 
Newbie

Joined: Wed Jan 12, 2005 10:03 am
Posts: 2
Location: Czech Republic
Hi all,

Is there some way how to get length of string type property using Hibernate API?

Code:
<property name="name"  type="string" length="50" />


I didn't found it in net.sf.hibernate.type.StringType or net.sf.hibernate.metadata.ClassMetadata.

My usecase for it is validation of string inputs in web forms (i use Tapestry).

Thanks for tips,

Rob


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 12, 2005 12:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
look for it via the Configuration instead of the more dense and not so detailed SessionFactory metadata.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 12, 2005 2:24 pm 
Newbie

Joined: Wed Jan 12, 2005 10:03 am
Posts: 2
Location: Czech Republic
this is the code:

Code:
Configuration cfg = blabla.getHibConfiguration();
PersistentClass persistentClass = cfg.getClassMapping(clazz);
Property property = persistentClass.getProperty(propertyName);

Iterator it = property.getColumnIterator();
if (it.hasNext()) {
    Column c = (Column) it.next();
    return c.getLength();
}


Thanks for your help Max.

Bye.

Rob


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 12, 2005 5:24 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hi Rob, it would be cool if you could take 1 hour to write a small entry in the wiki on metadata use :-D

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 11, 2005 9:21 am 
Newbie

Joined: Wed May 11, 2005 9:20 am
Posts: 4
hrobin wrote:
this is the code:

Code:
Configuration cfg = blabla.getHibConfiguration();
PersistentClass persistentClass = cfg.getClassMapping(clazz);
Property property = persistentClass.getProperty(propertyName);

Iterator it = property.getColumnIterator();
if (it.hasNext()) {
    Column c = (Column) it.next();
    return c.getLength();
}



We are using SpringFramework to wrapper Hibernate. So now the question is how to do this within spring?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 11, 2005 11:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Don't use spring, as I am pretty certain that they do not expose this "implementation detail".


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 11, 2005 11:37 am 
Newbie

Joined: Wed May 11, 2005 9:20 am
Posts: 4
Just got this from from Spring for those who us it

Code:
LocalSessionFactoryBean lsfb = (LocalSessionFactoryBean) ctx.getBean("&SessionFactory");
  Configuration cfg = lsfb.getConfiguration();


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.