-->
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: How to warp a persistent class directly from Hibernate?
PostPosted: Sun Jun 01, 2008 4:00 pm 
Newbie

Joined: Mon May 12, 2008 12:22 am
Posts: 6
I have some persistent classes generated by Hibernate synchronizer.
Suppose I have a class like this:
class Car{
public Long getId(){..}
public void setId(Long id){..}

public String getColor(){..};
public void setColor(String color){..}
}


Whenever I use CarDAO for any HQL query, I’m getting instances for the class Car like:
List<Car> findAll();


For some purposes, I created a class XCar:
Class XCar extends Car{
private Car car;
public XCar(Car c){
this.car = c;
}
….
}


My Question:
How to return XCar in all of my queries without doing that manually in every single method in CarDAO?

Note: Car.xml has the property lazy=”false”, means it is impossible to return a CGLIB proxy.

Note2: I read about EntityPersister, will it help me? If yes, kindly show me an example, because I couldn’t use it


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 02, 2008 9:08 am 
Hibernate Team
Hibernate Team

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

I've actually never heard of Hibernate Synchronizer before, but it seems this eclipse plugin has its own mailing list. Have you tried asking your question there?

As far as I understand Hibernate Synchronizer auto-generates some code for you. Are you asking how to modify these generated code or do you actually write your own HQL queries? In the latter case maybe ResultTransformers could help.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 02, 2008 9:37 am 
Newbie

Joined: Mon May 12, 2008 12:22 am
Posts: 6
hardy.ferentschik wrote:
Hi,

I've actually never heard of Hibernate Synchronizer before, but it seems this eclipse plugin has its own mailing list. Have you tried asking your question there?

As far as I understand Hibernate Synchronizer auto-generates some code for you. Are you asking how to modify these generated code or do you actually write your own HQL queries? In the latter case maybe ResultTransformers could help.

--Hardy

forget about Hibernate synchronizer, it just generates POJO classes, nothing more.
Anyway I found an answer,but I feel there is beter solution than this, wherever you create an HQL query,just say :
session.createQuery("Select new XCar(c) from Car c where ...")


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.