-->
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.  [ 6 posts ] 
Author Message
 Post subject: non persistent attribute in POJO
PostPosted: Wed Sep 07, 2005 2:22 pm 
Regular
Regular

Joined: Fri Mar 04, 2005 1:33 pm
Posts: 65
Location: U.K.
Hi

Is it possible to define a non-persistent attribute as simple as

private String myname ?

in hbm.xml file ?

The field 'myname' do not correspond to any column in the database table.

Thanks
Ron


Top
 Profile  
 
 Post subject: Re: non persistent attribute in POJO
PostPosted: Wed Sep 07, 2005 2:27 pm 
Pro
Pro

Joined: Fri Sep 02, 2005 4:21 am
Posts: 206
Location: Vienna
Hi,

rrr123 wrote:
Is it possible to define a non-persistent attribute as simple as

private String myname ?

in hbm.xml file ?

The field 'myname' do not correspond to any column in the database table.

I'm not sure to understand what you mean. If you don't want a class field to be persisted, just don't mention it in the mapping.

Did I miss somethng?

Erik


Top
 Profile  
 
 Post subject: non persistent attribute in POJO
PostPosted: Wed Sep 07, 2005 2:32 pm 
Regular
Regular

Joined: Fri Mar 04, 2005 1:33 pm
Posts: 65
Location: U.K.
Hi

Thanks for replying.

Well, I can define a non-persistent field in POJO, however I am using Middlegen to create POJO at build time. Once I define that non-persistent field in POJO, I need to move it into what we call a passive generation area and I will lose active generation of POJO each time I do a build. So, I was wondering there must be some way in hbm.xml file to specify non-persistent field ?

Thanks
Ron


Top
 Profile  
 
 Post subject: Re: non persistent attribute in POJO
PostPosted: Wed Sep 07, 2005 2:43 pm 
Pro
Pro

Joined: Fri Sep 02, 2005 4:21 am
Posts: 206
Location: Vienna
Hi,

rrr123 wrote:
So, I was wondering there must be some way in hbm.xml file to specify non-persistent field ?

Now I got it. The answer is yes. Set update and insert to false in your property - see Hibernate documentation http://www.hibernate.org/hib_docs/v3/re ... n-property

Erik


Top
 Profile  
 
 Post subject: non persistent attribute in hbm.xml
PostPosted: Wed Sep 07, 2005 4:10 pm 
Regular
Regular

Joined: Fri Mar 04, 2005 1:33 pm
Posts: 65
Location: U.K.
Hi

I am using Hibernate 2.1 and I defined property as you suggested:

<property name="userId" formula = "" type="java.lang.String" insert="false" update="false" >
<meta attribute="use-in-tostring">false</meta>
<meta attribute="use-in-equals">false</meta>
</property>

However still no luck ....

I see it is still getting included in Select clause when turn on Show Sql flag with following exception:

INFO: CORE3282: stdout: java.sql.SQLException: ORA-00904: "USER3_"."USERID": invalid identifier


Thanks
Ron


Top
 Profile  
 
 Post subject: Re: non persistent attribute in POJO
PostPosted: Wed Sep 07, 2005 8:42 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
rrr123 wrote:
Hi

Thanks for replying.

Well, I can define a non-persistent field in POJO, however I am using Middlegen to create POJO at build time. Once I define that non-persistent field in POJO, I need to move it into what we call a passive generation area and I will lose active generation of POJO each time I do a build. So, I was wondering there must be some way in hbm.xml file to specify non-persistent field ?

Thanks
Ron


There should be a way in middlegen to keep the field from being generated in the hibernate mapping.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


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