-->
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.  [ 5 posts ] 
Author Message
 Post subject: Help required reading propery attributes from hbm files
PostPosted: Tue Aug 12, 2008 5:38 am 
Newbie

Joined: Tue Aug 12, 2008 5:28 am
Posts: 4
Location: Pune India
Hi ,
I am not able to read property attributes like default value etc from hbm file, could any of you help me in doing that. I tried using ClassMetaData but it was of no help as I was only able to read specific attributes of any property and not all the attributes of the property.
I am using Hibernate 3 and Oracle db 10.2.0.3

Regards
Neeraj


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 12, 2008 6:23 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

could you be more specific? What property do you want to extract from which file. Generally properties are placed in hibernate.cfg.xml or hibernate.properties (peristence.xml in case you are using JPA) and given that you have an instance of Configuration you can just call Configuration.getProperties().

If you want to get access to the actual configuration data of a single mapped classed you will have to go via the meta data. The mapping data is not available as standalone values.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 12, 2008 6:34 am 
Newbie

Joined: Tue Aug 12, 2008 5:28 am
Posts: 4
Location: Pune India
asasa


Last edited by neerajkumar.gupta on Tue Aug 12, 2008 6:37 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 12, 2008 6:35 am 
Newbie

Joined: Tue Aug 12, 2008 5:28 am
Posts: 4
Location: Pune India
Actually I want to read property attributes from hibernate mapping file
like property column have values precision , unique , default, scale etc . I want to read these attributes from mapping file of particular table and use it in my program for making some validations.

sample mapping file :

<hibernate-mapping>
<class name="com.test.XYZ" table="TEST" schema="XYZ">
<id name="opid" type="big_decimal">
<column name="OPID" precision="22" scale="0" />
<generator class="assigned" />
</id>
<property name="name" type="string">
<column name="NAME" length="960" not-null="true" unique="true" />
</property>
<property name="description" type="string">
<column name="DESCRIPTION" length="4000" />
</property>
<property name="createcopy" type="big_decimal">
<column name="CREATECOPY" precision="22" scale="0" not-null="true" />
</property>
</class>
</hibernate-mapping>

I want to read unique attribute from property name
If you want some more details please do let me know

--Neeraj


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 13, 2008 5:52 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

I don't think you can read this values as properties. If it is not part of ClassMetaData you won't be able to get to it.
If you want to build validation into your domain model maybe Hibernate Validator is for you. Have you had a look at this project?

--Hardy


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