-->
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: logging returned objects prints out [Ljava.lang.Object;@6179
PostPosted: Sat Sep 16, 2006 10:42 am 
Beginner
Beginner

Joined: Sun Feb 12, 2006 12:19 am
Posts: 20
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.1


Code between sessionFactory.openSession() and session.close():
ArrayList<ReleaseScheduleBean> list = (ArrayList<ReleaseScheduleBean>)this.getHibernateTemplate().find("from " + ReleaseScheduleBean.class.getName() + " as rsBean inner join rsBean.milestone as msBean where msBean.productID = ? order by msBean.number" , id);

if(logger.isDebugEnabled())
{
for(int i = 0; list != null && i < list.size(); ++i)
{
logger.debug("ReleaseScheduleDAO list[" + String.valueOf(i) + "]:" + String.valueOf(list.get(i)));
}
}

Log output:

ReleaseScheduleDAO list[0]:[Ljava.lang.Object;@12f195
ReleaseScheduleDAO list[0]:[Ljava.lang.Object;@12f195
ReleaseScheduleDAO list[1]:[Ljava.lang.Object;@1b29f80
ReleaseScheduleDAO list[1]:[Ljava.lang.Object;@1b29f80
ReleaseScheduleDAO list[2]:[Ljava.lang.Object;@5b24c
ReleaseScheduleDAO list[2]:[Ljava.lang.Object;@5b24c
ReleaseScheduleDAO list[3]:[Ljava.lang.Object;@1fcd402
ReleaseScheduleDAO list[3]:[Ljava.lang.Object;@1fcd402
ReleaseScheduleDAO list[4]:[Ljava.lang.Object;@1c2ec05
ReleaseScheduleDAO list[4]:[Ljava.lang.Object;@1c2ec05
ReleaseScheduleDAO list[5]:[Ljava.lang.Object;@1558dc
ReleaseScheduleDAO list[5]:[Ljava.lang.Object;@1558dc
ReleaseScheduleDAO list[6]:[Ljava.lang.Object;@17d03c5
ReleaseScheduleDAO list[6]:[Ljava.lang.Object;@17d03c5
ReleaseScheduleDAO list[7]:[Ljava.lang.Object;@82a13a
ReleaseScheduleDAO list[7]:[Ljava.lang.Object;@82a13a
ReleaseScheduleDAO list[8]:[Ljava.lang.Object;@2726b2
ReleaseScheduleDAO list[8]:[Ljava.lang.Object;@2726b2
ReleaseScheduleDAO list[9]:[Ljava.lang.Object;@5da37c
ReleaseScheduleDAO list[9]:[Ljava.lang.Object;@5da37c
ReleaseScheduleDAO list[10]:[Ljava.lang.Object;@19845fb
ReleaseScheduleDAO list[10]:[Ljava.lang.Object;@19845fb
ReleaseScheduleDAO list[11]:[Ljava.lang.Object;@1a791f
ReleaseScheduleDAO list[11]:[Ljava.lang.Object;@1a791f
ReleaseScheduleDAO list[12]:[Ljava.lang.Object;@6179e
ReleaseScheduleDAO list[12]:[Ljava.lang.Object;@6179e


Name and version of the database you are using:
MySQL 4

I have an overloaded toString method so I don't understand why it's printing out [Ljava.lang.Object;@6179e instead of calling the objects toString method

Any Help?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 16, 2006 11:57 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
because each element is apparently an array.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 16, 2006 5:40 pm 
Beginner
Beginner

Joined: Sun Feb 12, 2006 12:19 am
Posts: 20
How come I'm getting an array of objects looks like I get two of the same ReleaseScheduleBean and then two of the MilestoneBean? Here is my query:

Code:
this.getHibernateTemplate().find("from " + ReleaseScheduleBean.class.getName() + " rsBean inner join rsBean.milestone msBean where msBean.productID = ? order by msBean.number" , id);


I'm expecting an ArrayList of ReleaseScheduleBeans with it's milestone property set with the joined MilestoneBean value.

Here's my mappings:

Code:
<hibernate-mapping>
   <class name="com.age.j.soft.hibernate.ReleaseScheduleBean" table="release_schedule">
      <id name="releaseScheduleID" column="release_schedule_id">
         <generator class="native" />
      </id>
      <many-to-one name="milestone" column="milestone_id" class="com.age.j.soft.hibernate.MilestoneBean" not-null="true"/>
      <!--  <property name="milestoneID" column="milestone_id"/> -->
      <property name="feature" column="feature"/>
   </class>
</hibernate-mapping>

<hibernate-mapping>
   <class name="com.age.j.soft.hibernate.MilestoneBean" table="milestone">
      <id name="milestoneID" column="milestone_id">
         <generator class="native" />
      </id>
      <property name="productID" column="product_id"/>
      <property name="tentativeDate" column="tentative_date" type="date"/>
      <property name="number" column="number"/>
      <property name="releaseDate" column="release_date" type="date"/>
      <property name="maxVersion" column="max_version"/>
      <property name="minVersion" column="min_version"/>
   </class>
</hibernate-mapping>


Here's my objects:

Code:
public class ReleaseScheduleBean implements Serializable{
   protected Integer releaseScheduleID = null;
   
   protected MilestoneBean milestone = null;
   
   //protected Integer milestoneID = null;
   
   protected String feature = null;
...


public class MilestoneBean implements Serializable{
   
   protected Integer milestoneID = null;
   
   protected Integer productID = null;

   protected Integer number = null;
   
   protected Date tentativeDate = null;

   
   //nullables
   
   protected Date releaseDate = null;

   protected Integer maxVersion = null;

   protected Integer minVersion = null;

...


Can you help me?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 17, 2006 3:08 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
SELECT foo from Foo, Bar


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 17, 2006 11:13 am 
Beginner
Beginner

Joined: Sun Feb 12, 2006 12:19 am
Posts: 20
I don't have to do any joins either in the query or the mapping file?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 17, 2006 11:37 am 
Beginner
Beginner

Joined: Sun Feb 12, 2006 12:19 am
Posts: 20
I got it but I had to put lazy="false" on the following mapping:

<many-to-one lazy="false" name="milestone" column="milestone_id" class="com.age.j.soft.hibernate.MilestoneBean" unique="true" not-null="true"/>

I don't understand why I was getting a lazy exception without it?

Can somebody explain?

Shawn


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.