-->
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: Object type problem with Hiberante Criteria Query
PostPosted: Tue Sep 28, 2010 10:18 pm 
Newbie

Joined: Tue Aug 29, 2006 2:54 am
Posts: 16
Dear all
I use hibernate 3.2.1
I have some code as below
Code:
Criteria cri = this.session.createCriteria( Book.class )
        .add( eq( "type" , "food" ) )
        .addOrder( Order.asc( "serNo" ) );
       
        cri.setFetchMode( "authorInfo" , FetchMode.JOIN );
        final List<Book> list = cri.list();

In the list , I expect the object type is com.test.book.
But all the object type in the list is com.test.book_$$_javassist_29
Because I use java reflection to do something in my code.
The object type will have influence.
Are there any wrongs with my code?

Thanks in advanced~


Top
 Profile  
 
 Post subject: Re: Object type problem with Hiberante Criteria Query
PostPosted: Tue Sep 28, 2010 11:11 pm 
Beginner
Beginner

Joined: Fri Mar 11, 2005 7:46 am
Posts: 29
You are getting back a proxy - if you need your Book class try different lazy options, eg. lazy="false". It should result in getting back Book class instead of proxy.


Top
 Profile  
 
 Post subject: Re: Object type problem with Hiberante Criteria Query
PostPosted: Wed Sep 29, 2010 1:36 am 
Newbie

Joined: Tue Aug 29, 2006 2:54 am
Posts: 16
kostaky wrote:
You are getting back a proxy - if you need your Book class try different lazy options, eg. lazy="false". It should result in getting back Book class instead of proxy.


Thanks for your reply.
The code is the snippet in my DAO class of the web application.
When I run the code for unit test in my local computer.
It will not get the proxy class.The console show com.test.book.

But When I deploy the web application application to the Tomcat and the user use the UI to operate the System. The snippet will get the proxy class when execute.

I wnat to know, why the code is same , but it works different in my local computer for unit test and Tomcat?

Thanks


Top
 Profile  
 
 Post subject: Re: Object type problem with Hiberante Criteria Query
PostPosted: Wed Sep 29, 2010 10:31 pm 
Beginner
Beginner

Joined: Fri Mar 11, 2005 7:46 am
Posts: 29
You should get same behaviour provided configuration and libraries are same. It could be some library issue - eg. your tomcat is missing cglib or javassist library, but you unit testing classpath does have it - make sure you have same configuration and runtime "environment" - have a look at hibernate required/optional library list. Also, which wrapper do you use for unit testing - it might also have some implications - eg. SpringJUnit4ClassRunner


Top
 Profile  
 
 Post subject: Re: Object type problem with Hiberante Criteria Query
PostPosted: Thu Sep 30, 2010 9:25 pm 
Newbie

Joined: Tue Aug 29, 2006 2:54 am
Posts: 16
I checked the libraries reference in eclipse and the depoyed libraries in the Tomcat.
The libraries are the same.

kostaky wrote:
You should get same behaviour provided configuration and libraries are same. It could be some library issue - eg. your tomcat is missing cglib or javassist library, but you unit testing classpath does have it - make sure you have same configuration and runtime "environment" - have a look at hibernate required/optional library list. Also, which wrapper do you use for unit testing - it might also have some implications - eg. SpringJUnit4ClassRunner


Top
 Profile  
 
 Post subject: Re: Object type problem with Hiberante Criteria Query
PostPosted: Thu Sep 30, 2010 10:14 pm 
Beginner
Beginner

Joined: Fri Mar 11, 2005 7:46 am
Posts: 29
Then step thru the code (in Debug mode) and see where the difference is.


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.