-->
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.  [ 13 posts ] 
Author Message
 Post subject: Migration issue from Annotation 3.3.0 to 3.3.1
PostPosted: Fri Jun 06, 2008 2:53 pm 
Newbie

Joined: Thu Apr 05, 2007 5:56 am
Posts: 13
Hibernate version:
Core : 3.2.6
Annotation : 3.3.1

Mapping documents:
Code:
@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
@OneToMany(fetch = FetchType.EAGER)
@JoinTable(name="ROLE_ACCESSRIGHT",
            joinColumns = @JoinColumn( name="ROLE_ID"),
            inverseJoinColumns = @JoinColumn( name="ACCESSRIGHTS_ID")
    )   
@org.hibernate.annotations.MapKey(columns = @Column(name="AppModule"))
@Enumerated(value=EnumType.STRING)
private Map<MenuEnum, AccessRight> accessRights = null;


Full stack trace of any exception that occurs:
Code:
org.hibernate.type.SerializationException: could not deserialize
   at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:217)
   at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:240)
   at org.hibernate.type.SerializableType.fromBytes(SerializableType.java:82)
   at org.hibernate.type.SerializableType.get(SerializableType.java:39)
   at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163)
   at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:154)
   at org.hibernate.persister.collection.AbstractCollectionPersister.readIndex(AbstractCollectionPersister.java:708)
   at org.hibernate.collection.PersistentMap.readFrom(PersistentMap.java:258)
   at org.hibernate.loader.Loader.readCollectionElement(Loader.java:1008)
   at org.hibernate.loader.Loader.readCollectionElements(Loader.java:646)
   at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:591)
   at org.hibernate.loader.Loader.doQuery(Loader.java:701)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
   at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
   at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
   at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
   at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3049)
   at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:399)
   at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
   at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
   at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:179)
   at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
   at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
   at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:846)
   at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:557)
   at org.hibernate.type.EntityType.resolve(EntityType.java:379)
   at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:120)
   at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:854)
   at org.hibernate.loader.Loader.doQuery(Loader.java:729)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
   at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
   at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
   at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
   at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3049)
   at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:399)
   at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
   at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
   at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
   at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
   at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
   at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:846)
   at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:557)
   at org.hibernate.type.EntityType.resolve(EntityType.java:379)
   at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:120)
   at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:854)
   at org.hibernate.loader.Loader.doQuery(Loader.java:729)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
   at org.hibernate.loader.Loader.doList(Loader.java:2213)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
   at org.hibernate.loader.Loader.list(Loader.java:2099)
   at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
   at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
   at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
   at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
Caused by: java.io.EOFException
   at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
   at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source)
   at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
   at java.io.ObjectInputStream.<init>(Unknown Source)
   at org.hibernate.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:252)
   at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:209)








Name and version of the database you are using:
Oracle 10g


Hello,

I have updated Annotation from 3.3.0 to 3.3.1
After this update, Hibernate send me a stack trace about deserialisation exception with this :
Code:
@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
@OneToMany(fetch = FetchType.EAGER)
@JoinTable(name="ROLE_ACCESSRIGHT",
            joinColumns = @JoinColumn( name="ROLE_ID"),
            inverseJoinColumns = @JoinColumn( name="ACCESSRIGHTS_ID")
    )   
@org.hibernate.annotations.MapKey(columns = @Column(name="AppModule"))
@Enumerated(value=EnumType.STRING)
private Map<MenuEnum, AccessRight> accessRights = null;


MenuEnum is an enum.

Before the update, ROLE_ACCESSRIGHT have a "AppModule" column with the value of the enum like :
Code:
"PLANIFICATION"


After the migration and some debug, "AppModule" have now a strange value like :
Code:
ACED00057E720025636F6D2E5[.....]742E7765622E66616365732E6D65E752E00C535441544953544951554553



Any idea about restoring the old value ?

Thanks for your help!


Nicolas[/code]


Last edited by NicolasL on Sat Jun 07, 2008 4:10 am, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 06, 2008 7:06 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hello,
I think you forgot the stacktrace you mention.

kind regards,

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 07, 2008 2:24 am 
Newbie

Joined: Thu Apr 05, 2007 5:56 am
Posts: 13
Hello,

I have put the stack trace.

I think i can fix my enum by 3 way :
- replacing the enum key by a string key
- creating an user type for my enum
- finding how to configure hibernate to take for the key the name of the enum


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 07, 2008 3:29 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
hi,
could you show the relevant parts of other involved entities?
How is "AccessRight" mapped?
and what entity contains the code you showed?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 07, 2008 3:56 am 
Newbie

Joined: Thu Apr 05, 2007 5:56 am
Posts: 13
Thanks for your help !

The roll class :

Code:
@Entity
@Table(uniqueConstraints={@UniqueConstraint(columnNames={"name"})})
public final class Role {

   @Id
   @GeneratedValue
   private String id;

   private String name = null;

   private String description = null;

@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
@OneToMany(fetch = FetchType.EAGER)
@JoinTable(name="ROLE_ACCESSRIGHT", joinColumns = @JoinColumn(name="ROLE_ID"), inverseJoinColumns = @JoinColumn( name="ACCESSRIGHTS_ID"))   
@org.hibernate.annotations.MapKey(columns = @Column(name="AppModule"))
@Enumerated(value=EnumType.STRING)
private Map<MenuEnum, AccessRight> accessRights = null;    

}



The AccessRight class :

Code:
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class AccessRight {
   
   @Id
   @GeneratedValue
   private String id;
   
   @Column(name = "AR_READ")
   private boolean read = false;
   
   @Column(name = "AR_CREATION")
   private boolean creation = false;
   
   @Column(name = "AR_UPDATE")
   private boolean update = false;
   
   @Column(name = "AR_DELETE")
   private boolean delete = false;
   
}



The MenuEnum enum :

Code:

public enum MenuEnum
{
   DT               (0 , "di" , "demande_de_travaux"),
   PLANIFICATION      (1 , "plan" , "planification"),
   GAMMESYSTEMATIQUE   (2 , "gsp" , "SY"),
   PLANMAINTENANCE      (3 , "pmp" , "PM"),
   PREVENTIVECR      (4 , "pcr" , "CR"),
   DONNEESTECHNIQUES   (5 , "dt" , "donnee_technique"),
   STOCK            (6 , "stock" , "stock"),
   STATISTIQUES      (7 , "stat" , "statistiques"),
   HISTORIQUE         (8 , "histo" , "historique"),
   GESTION            (10 , "gestion" , "gestion"),
   PARAMETRAGE         (9 , "param" , "parametrage");
   

   private int    numero;
   private String    id;
   private String   title;

   MenuEnum(int numero , String id , String title)
   {
      this.numero = numero;
      this.id = id;
      this.title = title;
   }

   
}



(I have removed the getter/setter)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 07, 2008 10:06 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
I never have seen a @GeneratedValue used on a String id;
Isn't it possible to switch to a Integer id?

Even if you can't change the schema, could you try to see if the problems are related?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 07, 2008 11:14 am 
Newbie

Joined: Thu Apr 05, 2007 5:56 am
Posts: 13
The @GeneratedValue works with a String. But I acknowledge that it's a serious flaw...
But I don't think there is a relation.


If I change the annotation from :

Code:
@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
@OneToMany(fetch = FetchType.EAGER)
@JoinTable(name="ROLE_ACCESSRIGHT", joinColumns = @JoinColumn(name="ROLE_ID"), inverseJoinColumns = @JoinColumn( name="ACCESSRIGHTS_ID"))   
@org.hibernate.annotations.MapKey(columns = @Column(name="AppModule"))
@Enumerated(value=EnumType.STRING)
private Map<MenuEnum, AccessRight> accessRights = null;   


To

Code:
@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
@OneToMany(fetch = FetchType.EAGER)
@JoinTable(name="ROLE_ACCESSRIGHT", joinColumns = @JoinColumn(name="ROLE_ID"), inverseJoinColumns = @JoinColumn( name="ACCESSRIGHTS_ID"))   
@org.hibernate.annotations.MapKey(columns = @Column(name="AppModule"))
private Map<String , AccessRight> accessRights = null;   



That works...


I think, the main issue was how Hibernate Annotation 3.3.1 see a key enum in a map.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 07, 2008 11:46 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
I'm sorry but I have taken the time
to test your entities with all your same annotations in a clean DB
and it just works ok, both persisting and queries.
I see the correct String in DB too.

I had to adapt the id to Integer, that's the only change I did; maybe beacuse of different DB,
I used Mysql 5.

So I still suggest you to try using Integer instead ;-)

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 07, 2008 1:18 pm 
Newbie

Joined: Thu Apr 05, 2007 5:56 am
Posts: 13
I have extracted the bean into a new projet and a new schema and adapted the id to Integer.

No way :(

The APPMODULE column is alway a RAW type

ROLE_ID 3.0 NUMBER 10.0
ACCESSRIGHTS_ID 3.0 NUMBER 10.0
APPMODULE -3.0 RAW 255.0


I will download mysql to test :)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 07, 2008 1:23 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
out of curiosity, what is your DB?
and other hibernate jar versions?
Please try updating all libs to latest stable.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 07, 2008 1:54 pm 
Newbie

Joined: Thu Apr 05, 2007 5:56 am
Posts: 13
Mysql (5.0.51b) doesn't want to create ROLE_ACCESSRIGHT table....

Code:
19:48:13 DEBUG : SchemaUpdate.execute:149 - create table ROLE_ACCESSRIGHT (ROLE_ID integer not null, ACCESSRIGHTS_ID integer not null, AppModule tinyblob, primary key (ROLE_ID, AppModule), unique (ACCESSRIGHTS_ID))
19:48:13 ERROR : SchemaUpdate.execute:155 - Unsuccessful: create table ROLE_ACCESSRIGHT (ROLE_ID integer not null, ACCESSRIGHTS_ID integer not null, AppModule tinyblob, primary key (ROLE_ID, AppModule), unique (ACCESSRIGHTS_ID))
19:48:13 ERROR : SchemaUpdate.execute:156 - BLOB/TEXT column 'AppModule' used in key specification without a key length


I have the lastest production release of Hibernate with the dependencies bundled with the zip. No other lib.

Hibernate 3.2.6 GA
Hibernate Annotations 3.3.1 GA
Hibernate EntityManager 3.3.2 GA


What is your version of Hibernate ?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 07, 2008 6:39 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Code:
create table ROLE_ACCESSRIGHT (ROLE_ID integer not null, ACCESSRIGHTS_ID integer not null, AppModule varchar(255), primary key (ROLE_ID, AppModule), unique (ACCESSRIGHTS_ID))

same hibernate versions... I'm sorry, I never see that "tinyblob" for AppModule :-(
I'm sorry I don't know how to help you any more;
we should hope a Hibernate Team member sees this thread and gives you some idea;
please let me know.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 09, 2008 3:59 pm 
Newbie

Joined: Thu Apr 05, 2007 5:56 am
Posts: 13
Could you test please my project ?

I have put the archive of the eclipse projet here.

Thanks for your help :)


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