-->
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: Dynamic instantiation in Hibernate tools(related to HBX-906)
PostPosted: Wed Apr 15, 2009 4:57 am 
Newbie

Joined: Wed Apr 15, 2009 4:43 am
Posts: 5
Hi,
I have a problem, the same as described in the JIRA issue http://opensource.atlassian.com/project ... se/HBX-906.
By reading the issue comments and searching around I wasn't able to find the info on if this issue is now solved or how to implement the toString() method in order to do some workaround.

Currently, what I have is this:

- I type the query in Editor window:
Code:
select new CompanyDetails(
   count(u), u.company.name
)
from User u          
group by u.company.name


-CompanyDetails class is implemented:
Code:
public class CompanyDetails {
   
   private Long numberOfTotalEmployees;
   private String companyName;
   
   public CompanyDetails(Long numberOfTotalEmployees, String companyName) {
      this.numberOfTotalEmployees = numberOfTotalEmployees;
      this.companyName = companyName;
   }

   public Long getNumberOfTotalEmployees() {
      return numberOfTotalEmployees;
   }

   public void setNumberOfTotalEmployees(Long numberOfTotalEmployees) {
      this.numberOfTotalEmployees = numberOfTotalEmployees;
   }

   public String getCompanyName() {
      return companyName;
   }

   public void setCompanyName(String companyName) {
      this.companyName = companyName;
   }
   
   @Override
   public String toString() {
      return "<" + this.companyName + "><" + this.numberOfTotalEmployees + ">";
   }
}


-The result I get in the "Hibernate Query Result" view is:
Quote:
-----------------------------------------
| <CompanyName><number> | ? |
-----------------------------------------
| <CompanyName><number> | ? |
-----------------------------------------

with no details available in the "Properties" view.

Any help on this one?

PS. I know other ways to retrieve information I'm trying with above way. But I want to use dynamic instantiation, and the above code is just a simple example. If the simplest doesn't work than what will work?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 15, 2009 7:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Just to understand, your question is how to get properties view of non-entities ?

We don't do that currently - the properties view only exposes the properties as known to hibernate.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 15, 2009 8:43 am 
Newbie

Joined: Wed Apr 15, 2009 4:43 am
Posts: 5
Thanks, I was not aware that properties of non-entities are not shown.

That was one of my "questions".

The other would be: why do I get result in form of List of Object[]? I would expect only the list of CompanyDetails in this case. I presume that the output I get in the "Hibernate Query Result" view means exactly that - List of arrays of size 2 where element at 0 position is the CompanyDetails instance and element at 1 position is '?' (I didn't tested this in the code but only in Hibernate Tools' editor).


Top
 Profile  
 
 Post subject: Re: Dynamic instantiation in Hibernate tools(related to HBX-906)
PostPosted: Tue May 05, 2009 6:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I'm not sure why you are getting that ? in the result. You should try it out independent of hibernate tools to investigate.

_________________
Max
Don't forget to rate


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.