-->
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.  [ 2 posts ] 
Author Message
 Post subject: Selection of objects with backreference
PostPosted: Wed Apr 04, 2007 2:27 am 
Newbie

Joined: Wed Mar 15, 2006 5:46 am
Posts: 2
Hibernate version:
3.2.0 GA (JEMS Installer 1.2.0), 3.2.1 (JBoss 4.2.0CR1)

Full stack trace of any exception that occurs:
ClassNotFoundException: [Lorg.jboss.aop.Inteceptor
Could not find marshaller for data type ('null'). Trying to load from server (from my memory)

Name and version of the database you are using:
MySQL 5.0.37, ConnectorJ 5.0.5

JDK 1.6.0 U1

Hi all,

I wrote an enterprise application which run under JBoss 4.0.4 without any problems. Yesterday I started to port it to an newer release of JBoss AS/Hibernate.

I had some problems with the new bag semantic of Lists<T> and so I changed all occurences of OneToMany and ManyToMany to include @IndexColumn("idx_col_name"). Could compile and run without problems.

After porting of serverside code, I started to port my clientside (Swing Client) code to the new relevant libs from JBoss 4.0.5GA. Everything seemed to be ok. But after first start of the application, I run into seriouse problems:
1. When I loaded arrays of entity objects. Solved: JBoss remoting patch 1.4.6. (JDK 1.6 ClassLoader problem)
2. The next problem occured, when I wanted to load objects, which include lists of objects of its own class type:



Code:

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

@Entity
public class OrganisationUnit implements Serializable {
   
   //    <node label="txtree.nodes.root.label" icon="home.png" desc="txtree.nodes.root.desc">
   
   @Id @GeneratedValue(strategy=GenerationType.AUTO)
   private long id;   
   
   @ManyToOne()   
   private OrganisationUnit parentUnit;
   
   @OneToMany(mappedBy="parentUnit", cascade=CascadeType.ALL, fetch=FetchType.EAGER)   
                @IndexColoumn(name="id")
   private List<OrganisationUnit> childUnits = new ArrayList<OrganisationUnit>();
   
   @OneToMany(mappedBy="organisationUnit", cascade=CascadeType.ALL, fetch=FetchType.EAGER)
                @IndexColoumn(name="id")
   private List<Function> functions = new ArrayList<Function>();
   
   private String label;
   private String icon;
   private String description;
   
   private boolean enabled = true;
   
   private boolean visible = true;
   
   private boolean expanded = false;

   private boolean displaySeparatorBefore = false;
   
   private boolean displaySeparatorAfter  = false;
   
   public List<OrganisationUnit> getChildUnits() {
      return childUnits;
   }
   
   public void setChildUnits(List<OrganisationUnit> childUnits) {
      this.childUnits = childUnits;
   }
   
   public String getDescription() {
      return description;
   }
   
   public void setDescription(String description) {
      this.description = description;
   }
   
   public boolean isDisplaySeparatorAfter() {
      return displaySeparatorAfter;
   }
   
   public void setDisplaySeparatorAfter(boolean displaySeparatorAfter) {
      this.displaySeparatorAfter = displaySeparatorAfter;
   }
   
   public boolean isDisplaySeparatorBefore() {
      return displaySeparatorBefore;
   }
   
   public void setDisplaySeparatorBefore(boolean displaySeparatorBefore) {
      this.displaySeparatorBefore = displaySeparatorBefore;
   }
   
   public boolean isEnabled() {
      return enabled;
   }
   
   public void setEnabled(boolean enabled) {
      this.enabled = enabled;
   }
   
   public List<Function> getFunctions() {
      return functions;
   }
   
   public void setFunctions(List<Function> fuctions) {
      this.functions = fuctions;
   }
   
   public String getIcon() {
      return icon;
   }
   
   public void setIcon(String icon) {
      this.icon = icon;
   }
   
   public String getLabel() {
      return label;
   }
   
   public void setLabel(String label) {
      this.label = label;
   }
   
   public OrganisationUnit getParentUnit() {
      return parentUnit;
   }
   
   public void setParentUnit(OrganisationUnit parentUnit) {
      this.parentUnit = parentUnit;
   }
   
   public long getId() {
      return id;
   }

   public boolean isExpanded() {
      return expanded;
   }

   public void setExpanded(boolean expanded) {
      this.expanded = expanded;
   }

   public boolean isVisible() {
      return visible;
   }

   public void setVisible(boolean visible) {
      this.visible = visible;
   }
   
   
}



Selection HQL is: FROM OrganisationUnit WHERE parentUnit IS NULL.

In the database there only exists one single entry with parentUnit IS NULL.

After doing the corresponding remote call to an ssb I get one single entity instance of OrganisationUnit. BUT when I loop over the list of chield Units:

Code:
for (OrganistionUnit subOU: ouHome.getChildUnits()) {
   ...
}


Some of the list elements are null! But they cant be null, I checked this over and over again. I am getting the right number of elements.
Interesting is, that the null-elements are elements, which do not have chieldUnits them self. If a subOU has one or more chield units, all its attributes are filled correctly. The problems seems to be recursive.

I could not solve this issue, so I tried JBoss 4.2.0CR1 with Hibernate 3.2.1 but got the same problem.

Does anyone had erros like my one?

Thank you.

Meikel


Top
 Profile  
 
 Post subject: Indexcolumn
PostPosted: Wed Apr 04, 2007 6:07 am 
Regular
Regular

Joined: Wed Aug 24, 2005 11:49 am
Posts: 63
I think it is because you use 'id' as indexcolumn.
Hibernate normally updates the indexcolumn to maintain the collection order.

When loading the collection, you will get a list with the elements on the position of the value of 'id', and null on all other positions in the list (since a list can contain null values, this is what Hibernate SHOULD do).

_________________
Edwin van der Elst
Finalist IT Group


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