-->
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.  [ 5 posts ] 
Author Message
 Post subject: Retrieving a list of Blobs
PostPosted: Tue Aug 22, 2006 6:35 am 
Newbie

Joined: Tue Aug 22, 2006 6:12 am
Posts: 5
Dear all,

I am new on hibernate and am currently running into trouble with the persistence of a list of blobs.

I have a class BlobData wich is used as a value type in another class Project. Projekt contains a java.util.List 'blobs'.

Code:
public class Project implements Serializable {

   /**
    *
    */
   private static final long serialVersionUID = 1L;

   /** identifier field */
   private long id;

   /** nullable persistent field */
   private String name;

               private List blobs;

[...]
/**
  *
  * @return the List value of blobs.
  */
  public List getBlobs(){
     return blobs;
  }

  /**
  *
  * @param blobs - the new value for blobs
  */s
  private void setBlobs(List blobs){
     blobs = blobs;
  }

  public void addBlob(BlobData blob){
      blobs.add(blob);
  }





The mapping for this class looks like that:

<class name="Project" >
<id name="id" type="long" column="projektID" unsaved-value="0">
<generator class="native"/>
</id>
<property name="name" type="java.lang.String" >
<column name="name" not-null="false"/>
</property>

<list name="blobs">
<key column="projektID"/>
<list-index column="blobNr" />
<composite-element class="prozessdb.db.BlobData">
<property name="bez" type="java.lang.String">
<column name="bezeichnung" not-null="false"/>
</property>
<property name="inhalt">
<column name="inhalt" sql-type="LONGBLOB" />
</property>
</composite-element>
</list>

</class>

It is no problem to store BlobData objects in the Database. But whenever I retrieve a Project form the Database my blobs Object equals null.
Why is Hibernate not keeping a reference for the list?

Any hints would be very helpful.

Regards,

Udo


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 22, 2006 7:18 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
there is no table attribute in list.

Please, don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 22, 2006 7:54 am 
Newbie

Joined: Tue Aug 22, 2006 6:12 am
Posts: 5
pepelnm wrote:
there is no table attribute in list.

Please, don't forget to rate.


You do not need it. It defaults to the given name. As I said, making blobs persistent is not the problem. A table blobs is beeing generated and a foreignkey 'projektID' is added to the table. My Problem is that after retrieving a project from the database the blobs member is always null.

I am using the following Query:

Query query = session.createQuery(
"FROM Project AS p " +
"WHERE p.name= :projectname");

query.setString("projectname", "Project 3");

Regards,

Udo


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 22, 2006 8:04 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
HAH HAH HAH HAH
Code:
private void setBlobs(List blobs){
   blobs = blobs;
}


Can you see it?

Please, don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 22, 2006 11:11 am 
Newbie

Joined: Tue Aug 22, 2006 6:12 am
Posts: 5
pepelnm wrote:
HAH HAH HAH HAH
Code:
private void setBlobs(List blobs){
   blobs = blobs;
}


Can you see it?

Please, don't forget to rate.


rol!!!!

I was just thinking of a more complicated error! Thanxx a lot for opening my eyes!


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