-->
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: Map returns a MarkerObject from Map.remove()!!!
PostPosted: Thu Aug 02, 2007 3:58 pm 
Newbie

Joined: Mon Feb 20, 2006 8:05 pm
Posts: 8
Emmanuel, I think I found another bug. I have an entity that contains a persistent map property that will return a reference to org.hibernate.util.MarkerObject from the map's remove() method if the map's contents haven't already been lazy-loaded in. I've prepared a minimal set of entities that reliably recreate the problem--shall I post them here or skip straight to a JIRA entry?

Hibernate version:
Hibernate Core 3.2.5.ga
Hibernate Annotations 3.3.0.ga

Name and version of the database you are using:
SQL-Server 2005


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 03, 2007 2:18 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
maybe, I don't really know what you're talking about. Detail the problem a bit more here.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 03, 2007 3:01 pm 
Newbie

Joined: Mon Feb 20, 2006 8:05 pm
Posts: 8
To demo, I created 3 entities: MapHolderEntity, MapKeyEntity, and MapValueEntity. MapKeyEntity has no associations. MapHolderEntity holds a @OneToMany map of MapKeyEntities to MapValueEntities, where MapValueEntity has a @ManyToOne back to both MapKeyEntity and MapHolderEntity. Here are snippets of the entities:

Code:
@Entity
public class MapHolderEntity
{
   // ...
   @Id
   @GeneratedValue( strategy = GenerationType.AUTO )
   public Long getId() { return id; }
   public String getName() { return name; }

   @OneToMany( mappedBy = "holder", cascade = CascadeType.ALL )
   @MapKey( name = "mapKey" )
   public Map<MapKeyEntity, MapValueEntity> getMap() { return map; }
   // ...
}

@Entity
public class MapKeyEntity
{
   // ...
   @Id
   @GeneratedValue( strategy = GenerationType.AUTO )
   public Long getId() { return id; }
   public String getName() { return name; }
   // ...
}

@Entity
public class MapValueEntity
{
   // ...
   @Id
   @GeneratedValue( strategy = GenerationType.AUTO )
   public Long getId() { return id; }
   public String getName() { return name; }

   @ManyToOne
   public MapKeyEntity getMapKey() { return mapKey; }

   @ManyToOne
   public MapHolderEntity getHolder() { return holder; }
   // ...
}



Now, if I populate them with some values and then do the following test:

Code:
public class MapStuffBugDemo extends ...
{
   // ...
   private GenericDao<MapHolderEntity, Long>   mhDao   = null;
   private GenericDao<MapKeyEntity, Long>      mkDao   = null;


   @Test
   public void demoBug()
   {
      try
      {
         mhDao = new GenericDao<MapHolderEntity, Long>( MapHolderEntity.class );
         mkDao = new GenericDao<MapKeyEntity, Long>( MapKeyEntity.class );

         MapHolderEntity mh = mhDao.findById( 1L );
         MapKeyEntity mk = mkDao.findById( 1L );

         // log.info( mh.getMap().get( mk ).getClass() );
         Object o = mh.getMap().remove( mk );
         
         log.info( o.getClass() );  // This line outputs some hibernate MarkerObject class name

         HbnSessionUtil.rollbackOnly();
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }
   }
}


If I hydrate a MapHolderEntity that has a nonempty map of MapKeyEntities to MapValueEntities and immediately call remove() on that map, the object returned by the remove() method is not of the type MapValueEntity, it is of the type org.blah.hibernate.MarkerObject. If I uncomment out the line before the map.remove(), that causes the map to lazy load in. If the map is lazy-loaded in, then map.remove() returns the right thing. If the above snippet behaves the way I'm representing, then I think this is pretty conclusive proof of a problem. Shouldn't PersistentMap.remove() fire off the lazy-loading logic? I can post a zip of all my test entities to a JIRA task if you want.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 03, 2007 8:02 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2768

That would be cool if you could attach your case (in hbm.xml file even better).

_________________
Emmanuel


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.