-->
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.  [ 1 post ] 
Author Message
 Post subject: SybaseDialect have missing 'real' data type registration.
PostPosted: Wed Jul 04, 2007 10:52 am 
Newbie

Joined: Wed Jul 04, 2007 10:30 am
Posts: 1
Location: Argentina
(i have Hibernate 3.2.3)
Hi, i was tring to make an Entity class that match a table that I have in my Sybase DB. that table's structure can't be modified because belongs to another legacy system.
My problem was that some columns data types was 'real', and it seems to be that SybaseDialect (or Sybase11Dialect) does not have the 'real' type (java.sql.Types = 7) registered, so i couldn't make a match defining the attribute in my class as float nor double.
So... what i did is to create a subclass or SybaseDialect like this:

Code:
import java.sql.Types;

public class SybaseDialect extends org.hibernate.dialect.SybaseDialect {
    public SybaseDialect() {
        super();
        registerColumnType(Types.REAL, "real");
    }
}


next, I had to create a data type in this way:

Code:
import java.sql.Types;
import org.hibernate.type.FloatType;

public class RealType extends FloatType {
    public int sqlType() {
        return Types.REAL;
    }
    public String getName() {
        return "real";
    }
}


later, Hibernate stopped complaining about expected data types complainings.

I don't know (i couldn't found nothing) if there's a better way, or if the problem is already solved, but if it's solved, please someone tell me :D (i don't like making custom dialects and datatypes for such a common thing)

Now i would like to declare my new type using @TypeDef annotation but Hibernate keep complaining like if i never write the Typedef.

this is my definition... (i putted it at class level)

Code:
@TypeDef(name = "real", typeClass = RealType.class, parameters = {})

or
Code:
@TypeDef(name = "real", typeClass = RealType.class)


and in my class i use it like this:

Code:
@Type(type = "real")
@Column(name = "heatingValue", nullable = false)
private float heatingValue;


This is the Exception:
Code:
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.MappingException: Could not determine type for: real, for columns: [org.hibernate.mapping.Column(heatingValue)]


I will appreciate some light here... thanks!

_________________
Emiliano.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.