-->
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: Define the type of the column using @Lob
PostPosted: Tue Jul 04, 2006 7:07 pm 
Newbie

Joined: Sat Aug 13, 2005 2:35 pm
Posts: 4
Hibernate version:
hibernate core: 3.2
hibernate entity manager: 3.2

Well, I'd like to know how can I set the type of the column created with the annotation @Lob. The problem is that this annotation is creating a BLOB column in my database, which is by the way MySQL, and I need it to be a MEDIUMBLOB or a LONGBLOB

thanks in advance!!!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 05, 2006 1:33 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
This is the code that does this:
Code:
      else if ( property.isAnnotationPresent( Lob.class ) ) {

         if ( mappings.getReflectionManager().equals( returnedClassOrElement, java.sql.Clob.class ) ) {
            type = "clob";
         }
         else if ( mappings.getReflectionManager().equals( returnedClassOrElement, java.sql.Blob.class ) ) {
            type = "blob";
         }
         else if ( mappings.getReflectionManager().equals( returnedClassOrElement, String.class ) ) {
            type = StringClobType.class.getName();
         }
         else if ( mappings.getReflectionManager().equals( returnedClassOrElement, Character.class ) && isArray ) {
            type = CharacterArrayClobType.class.getName();
         }
         else if ( mappings.getReflectionManager().equals( returnedClassOrElement, char.class ) && isArray ) {
            type = PrimitiveCharacterArrayClobType.class.getName();
         }
         else if ( mappings.getReflectionManager().equals( returnedClassOrElement, Byte.class ) && isArray ) {
            type = ByteArrayBlobType.class.getName();
         }
         else if ( mappings.getReflectionManager().equals( returnedClassOrElement, byte.class ) && isArray ) {
            type = PrimitiveByteArrayBlobType.class.getName();
         }
         else if ( mappings.getReflectionManager()
               .toXClass( Serializable.class )
               .isAssignableFrom( returnedClassOrElement ) ) {
            type = SerializableToBlobType.class.getName();
            //typeParameters = new Properties();
            typeParameters.setProperty(
                  SerializableToBlobType.CLASS_NAME,
                  returnedClassOrElement.getName()
            );
         }
         else {
            type = "blob";
         }
      }


So check how this X[Blob|Clob]Type classes are mapped into db.

Rgds, Ales


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 06, 2006 8:52 am 
Newbie

Joined: Sat Aug 13, 2005 2:35 pm
Posts: 4
ok man, this code seems to be what I need to solve my problem, but I have no idea how to use it!!!
In which class should I put this code???
Could you post me an example???

regards,
Eduardo Zanoni Marques.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 06, 2006 3:21 pm 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
No, no, no ... this IS the code that determines what type will be mapped.

What you should do is check out X[Blob|Clob]Types classes - and what matching sql type do they use.

If there is still no suitable type - write your own UserType - see how it is done in previous type lob classes.

Rgds, Ales


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.