-->
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.  [ 3 posts ] 
Author Message
 Post subject: Foriegn key value generation
PostPosted: Mon Jul 19, 2010 12:40 pm 
Newbie

Joined: Mon Jul 19, 2010 10:37 am
Posts: 5
Hi
I am using the Hibernate Tools to generate the POJO with Eclipse ,I want to customize the Template the so that Foreign key column value can also be available without using method chaining

Exa:- Table EMP {
Number ID(PK)
VARCHAR2 Name
Dept ID(FK)
}

Table Dept {
Number Dept_ID
VARCHAR2 NAme
}

When POJO generate for Employee table it doesn't contain the directly getter/setter method to get Dept_ID value ,you have to use the relationship (one to many/one to one) method to access the Dept table record.



So my question is how I can add automatically some transient method which can give me access Dept_Id value in the EMP pojo,I don't want to write extra query in my code for such kind of scenario .

I am trying to change the .ftl file/reverse engineering.xml for that ,but not able to understand exactly where I need to change ,as I changed tamplate for Caching also


Thanks in Advances.


Sanjay


Top
 Profile  
 
 Post subject: Re: Foriegn key value generation
PostPosted: Tue Jul 20, 2010 1:59 pm 
Newbie

Joined: Mon Jul 19, 2010 10:37 am
Posts: 5
Thanks for Reply,

problem is ,if I use the that method to fetch the Employee dept_id,in Business class ,not in Hibernate session
then it gives the Lazy initialization Exception no session for,because
"Employee.getDept().getId()" this stmt can only work with hibernate session(DAO Class),I don't want to use fetch type as EAGAR.

I want to access the complete object of EMP POJO n Business tier.


Top
 Profile  
 
 Post subject: Re: Foriegn key value generation
PostPosted: Wed Jul 21, 2010 11:57 am 
Newbie

Joined: Mon Jul 19, 2010 10:37 am
Posts: 5
Thanks for Reply,
Yes for doing that ,currently pojo.ftl is also have the PojoExtraClassCode.ftl ref
but PojoExtraClassCode.ftl file is using when we are using Meta-Data(hbm.xml),now question is what will be the magic stmt inside that ftl,I am just trying to figure out

current structure of PojoExtraClassCode.ftl is

<#if pojo.hasMetaAttribute("class-code")> // The following is extra code specified in the hbm.xml files
${pojo.getExtraClassCode()}
// end of extra code specified in the hbm.xml files
</#if>


Extra method name will dynamically generate so how that can be doable using custom ReverseEngineeringStrategy.


Thanks a lot


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