-->
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: SerializationException: could not deserialize
PostPosted: Thu Jan 14, 2010 8:54 pm 
Beginner
Beginner

Joined: Thu Jan 29, 2009 1:24 am
Posts: 20
Hi,

I've got an entity class which contains a java.util.UUID. Since my database is MySQL and it does not support the UUID type I have explicitly declared the column definition to be a varchar(36). My code looks like the following:

Code:
@Entity
@Table(name = "my_table")
public class MyClass
{
    private UUID uuid;

    @Column(columnDefinition = "varchar(36)", updatable = false, unique = true)
    public UUID getUuid()
    {
        return uuid;
    }

    public void setUuid(UUID uuid)
    {
        this.uuid = uuid;
    }
}


Unfortunately I am having a problem with retrieving objects from the database as it seems Hibernate doesn't know how to convert a UUID to String or vice versa. Now I realize I could make the internal field a String and annotate that instead of the getter but that creates a problem when I need subclasses to be able to override the annotations and still get all the base class annotations.

So is there a way to tell Hibernate to use some other serializer or can create I create a custom one? or is there a better way to store UUID in MySQL? Any help is greatly appreciated.


Top
 Profile  
 
 Post subject: Re: SerializationException: could not deserialize
PostPosted: Wed Jan 27, 2010 12:47 am 
Newbie

Joined: Wed Jan 27, 2010 12:45 am
Posts: 9
I'm working on the same problem right now.

Has anyone found a good option for this? I would prefer to store as a varbinary or binary(16) in mysql to save space but right now it appears String is the best option?

BTW anyone know why java.util.UUID doesn't have a getBytes method that returns a byte array?


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.