-->
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: Class Mapping and non-mapped property?
PostPosted: Wed Jul 15, 2009 10:18 am 
Newbie

Joined: Wed Jul 15, 2009 10:09 am
Posts: 2
I have a class mapping in which I would like to have a particular value populated in the database for this type of class; however, I do not need this property mapped to the class(i.e. no getter or setter). In my example below what I am trying to achieve is have the DOCUMENT_TYPE column populated with "GLOBAL" on the initial insert of this type of object. It currently does not work because hibernate complains that it could not find a getter for "docType" property. Is there a way to define a property but not have it mapped to a property in the class?

Code:
    <class name="GlobalDocument" table="DOCUMENTS">
        <id name="id" column="DOC_ID">
            <generator class="native"/>
        </id>
        <snipped>
        <property name="docType"  update="false">
           <column name="DOCUMENT_TYPE" default="GLOBAL"/>
        </property>
       
    </class>



Thanks


Top
 Profile  
 
 Post subject: Re: Class Mapping and non-mapped property?
PostPosted: Wed Jul 29, 2009 10:19 am 
Newbie

Joined: Wed Jul 15, 2009 10:09 am
Posts: 2
Any suggestions? Thanks


Top
 Profile  
 
 Post subject: Re: Class Mapping and non-mapped property?
PostPosted: Wed Jul 29, 2009 3:25 pm 
Regular
Regular

Joined: Mon Apr 19, 2004 6:54 pm
Posts: 79
check 'Custom SQL for create, update and delete' in the doc:
http://docs.jboss.org/hibernate/stable/core/reference/en/html/querysql.html#querysql-cud

Christophe


Top
 Profile  
 
 Post subject: Re: Class Mapping and non-mapped property?
PostPosted: Wed Jul 29, 2009 5:21 pm 
Beginner
Beginner

Joined: Wed Jul 29, 2009 3:43 pm
Posts: 22
You can use a formula e.g.
<property name="MyProp" formula="MyFormula"/>


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.