-->
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.  [ 9 posts ] 
Author Message
 Post subject: Simple query and javassist
PostPosted: Mon Oct 07, 2013 8:06 pm 
Newbie

Joined: Mon Oct 07, 2013 5:25 am
Posts: 7
Hi,

I have a simple query running that produces a list of entities. The entites seem to be javassist proxies, but how do I 'un-proxy' them?

Session sess = Util.getHibernateSession(em);
Query qry = sess.createQuery("select p from Person p where p.lastName = 'Smith'");

List<Object> people = qry.list();
for(Object obj : people) {
System.out.println(obj.toString());
}

-->
[Ljava.lang.Object;@2692c09e
[Ljava.lang.Object;@4897002a

Any ideas?


Top
 Profile  
 
 Post subject: Re: Simple query and javassist
PostPosted: Tue Oct 08, 2013 3:18 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Hi,

Quote:
-->
[Ljava.lang.Object;@2692c09e
[Ljava.lang.Object;@4897002a



These seem not to be proxies but rather Java arrays, which is odd though since your query selects the entire person object and not a projection of its attributes. You could inspect the output e.g. using Arrays.toString(), it would be interesting to know the array contents. Also, which version of OGM and which backend are you using?

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
 Post subject: Re: Simple query and javassist
PostPosted: Tue Oct 08, 2013 5:14 am 
Newbie

Joined: Mon Oct 07, 2013 5:25 am
Posts: 7
Hi Gunnar,

Thank you for your reply.

Yes, you are correct, each item in the returned list is an array. Each array is of size 1, containing the (javassisted proxy to the Person found). So I can get the result I desire, but obviously something amiss.

Of note is that qry.getReturnTypes() produces a single item item array containing a org.hibernate.type.ManyToOneType(com.trainasone.app.vaadin.person.Person)

I'm using hibernate-ogm 4.0.0.Beta3, and infinispan 5.3.0.Final

Anything else I can do, or other information I could provide to help get to the bottom of this?

Best regards,

Sean


Top
 Profile  
 
 Post subject: Re: Simple query and javassist
PostPosted: Tue Oct 08, 2013 8:28 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
Hi sean,
could you provide a test?

Davide


Top
 Profile  
 
 Post subject: Re: Simple query and javassist
PostPosted: Wed Oct 09, 2013 6:32 am 
Newbie

Joined: Mon Oct 07, 2013 5:25 am
Posts: 7
Hi Davide,

Yes I will put a test case together. I presume a zip/tarball of a test maven project will be acceptable?

Thanks,

Sean


Top
 Profile  
 
 Post subject: Re: Simple query and javassist
PostPosted: Thu Oct 10, 2013 3:15 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Hi Sean,

Yes, either that or just post the code here. The more concise the test case the better :) Thanks for your efforts, its much appreciated.

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
 Post subject: Re: Simple query and javassist
PostPosted: Thu Oct 10, 2013 7:32 am 
Newbie

Joined: Mon Oct 07, 2013 5:25 am
Posts: 7
Davide, Gunnar,

I have a test project for you. Cannot see an upload option to attach it to this forum though. Where would you like me to put it?

Regards,

Sean


Top
 Profile  
 
 Post subject: Re: Simple query and javassist
PostPosted: Fri Oct 11, 2013 5:15 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Hi Sean,

I can confirm the issue and have filed https://hibernate.atlassian.net/browse/OGM-346 for it. You can attach your test case to this issue.

As a workaround, just omit the "select p" part from your query, i.e. execute "from Person p where p.lastName = 'Smith'" instead. This will return a list of Person objects.

Thanks for spotting this problem,

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
 Post subject: Re: Simple query and javassist
PostPosted: Fri Oct 11, 2013 5:25 am 
Newbie

Joined: Mon Oct 07, 2013 5:25 am
Posts: 7
Hi Gunnar,

Project attached to JIRA and thanks for the work-a-round (it does indeed work)

:D

Sean


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