-->
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: how not to map an element in the .hbm.xml file
PostPosted: Tue Oct 12, 2004 4:49 am 
Newbie

Joined: Fri Mar 26, 2004 7:23 am
Posts: 19
hi all,

We are integrating a struts-spring application with hibernate.

i have a DTO which has some variables.And i have mentioned the same in

my .hbm.xml file.

Now I have a variable which is a sort of a temporary var. it does not

exists in the database table.

How should i map this in my .hbm.xml file so that i get the methods in the

generated POJO class.

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 12, 2004 11:09 pm 
Regular
Regular

Joined: Tue Sep 09, 2003 9:37 pm
Posts: 56
Location: Ogden, Utah, USA
I have not tried it, but maybe setting insert="false" update="false" in your property definition would do the trick.
<property
name="propertyName"
column="column_name"
type="typename"
update="true|false"
insert="true|false"
formula="arbitrary SQL expression"
access="field|property|ClassName"
/>

good luck!

Jenica


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 13, 2004 2:13 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Sorry, this will not work. Hibernate would still try to use the property for selects.

Read chapter '15.2.2 The meta attribute' of the reference manual. IMHO the class-code or extends attributes are for you.
An other way would be to extend the generated POJO.

HTH
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 13, 2004 5:42 am 
Newbie

Joined: Fri Mar 26, 2004 7:23 am
Posts: 19
hi ,

I tried with this piece of code and was able to get the work done.


<property name="longDescription" type="string" insert="false"
update="false">
<meta attribute="field-description">The name of the Country</meta> </property>


Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 13, 2004 7:38 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Mmm ... Are you sure this works if you do session.get(POJO.class, id)?

IMHO this will result in Hibernate asking for a longDescription field as soon you try to load an instance of you POJO. I'd expect an SQLException.

HTH
Ernst


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.