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: Hibernate can't find entity with valid id
PostPosted: Thu Jul 21, 2011 4:06 am 
Newbie

Joined: Thu Apr 01, 2010 6:36 am
Posts: 7
Hi,

I've got a table with all the UN Locations there are, e.g. 'GB LON' is the UN Location code for London, UK,
NL RTM is the UN Location code for Rotterdam, Netherlands. This UN code is used as the primary key in the table.

Code:
@Id
   @Column(name = "LOCODE", unique = true, nullable = false, length = 6)
   @NotNull
   @Length(max = 6)
   public String getLocode() {
      return this.locode;
   }

Now for some reasons I can't explain I sometimes get a EntityNotFoundException, and it is always the UN Locode 'NL RTM' (or nl rtm doesn't seem to matter). Normally this works fine and the entity is clearly in the database.

Code:
javax.persistence.EntityNotFoundException: Unable to find com.mycompany.entity.UnLocode with id nl rtm
        at org.hibernate.ejb.Ejb3Configuration$Ejb3EntityNotFoundDelegate.handleEntityNotFound(Ejb3Configuration.java:113)
        at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:171)
        at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:223)
        at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:126)
        at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:905)
        at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:873)
        at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:590)
        at org.hibernate.type.EntityType.resolve(EntityType.java:412)
        at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:139)
        at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:877)
        at org.hibernate.loader.Loader.doQuery(Loader.java:752)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
        at org.hibernate.loader.Loader.loadCollection(Loader.java:2015)
        at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:59)
        at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:587)
        at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:83)
        at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1743)
        at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:366)
        at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:108)
        at org.hibernate.collection.PersistentBag.iterator(PersistentBag.java:272)



Any idea what could be the cause for it?

Regards

Immo


Top
 Profile  
 
 Post subject: Re: Hibernate can't find entity with valid id
PostPosted: Thu Jul 21, 2011 4:52 am 
Newbie

Joined: Thu Apr 01, 2010 6:36 am
Posts: 7
Okay found the problem. The data was wrong.
One entity which had a foreign key to the UnLocode had the UN code in lower case. Insuring that the keys are all upper case fixed it.


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.