-->
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.  [ 3 posts ] 
Author Message
 Post subject: Unable to convert between java.lang.Integer and BINARY
PostPosted: Fri Mar 30, 2007 5:05 pm 
Newbie

Joined: Fri Mar 30, 2007 4:43 pm
Posts: 3
In implementing some auditing code I took the time to make serializable some of our domain objects that were lacking the marker interface. But now it appears that somewhere in hibernate it is assuming one or more persistent class associations are saved/retrieved as blobs when in fact they have their own mappings defined? I've gone through the mapping files and tried to verify that all associations (especially the many-to-[one|many]) have defined the class to use (based on the assumption that hibernate is seeing a serializable implementation and not inspecting further) and yet I am still running into this problem. It is possible I have missed some and I will continue to look for ambiguous associations but is that even likely the problem? Is this a bug in hibernate that has maybe been fixed? (I am using an older 3.0 or 3.1 series and do not have the time to vet the latest with our application).

the stack trace:
Code:
16:52:17,600 ERROR [[action]] Servlet.service() for servlet action threw exception
org.hibernate.exception.GenericJDBCException: could not execute query
        at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82)
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at org.hibernate.loader.Loader.doList(Loader.java:1596)
        at org.hibernate.loader.Loader.list(Loader.java:1577)
        at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:111)
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1322)
        at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:300)
        at com.g1440.siteauthor.service.ModuleTypeService.findTypes(ModuleTypeService.java:50)
    [snipped for brevity]
Caused by: java.sql.SQLException: Unable to convert between java.lang.Integer and BINARY.
        at net.sourceforge.jtds.jdbc.Support.convert(Support.java:558)
        at net.sourceforge.jtds.jdbc.JtdsResultSet.getBytes(JtdsResultSet.java:714)
        at net.sourceforge.jtds.jdbc.JtdsResultSet.getBytes(JtdsResultSet.java:988)
        at org.jboss.resource.adapter.jdbc.WrappedResultSet.getBytes(WrappedResultSet.java:238)
        at org.hibernate.type.BinaryType.get(BinaryType.java:64)
        at org.hibernate.type.SerializableType.get(SerializableType.java:34)
        at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77)
        at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68)
        at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:759)
        at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:292)
        at org.hibernate.loader.Loader.doQuery(Loader.java:412)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)


the mapping:
Code:
<class name="com.g1440.siteauthor.data.ModuleType" table="[ModuleType]">
      <id name="id" column="moduleTypeID">
         <generator class="identity" />
      </id>
      
      <property name="name" />
      <property name="pluralName" />
      <property name="hasPublishDate" />
      <property name="createdBy" />
      <property name="createDate" type="timestamp" />
      <property name="lastUpdatedBy" />
      <property name="lastUpdateDate" type="timestamp" />
   </class>


offending code (as per stack trace):
Code:
    public static List findTypes(ModuleType example) {
       
        log.debug("Searching module types");
       
        if (example == null) {
            throw new IllegalArgumentException();
        }

        Session session = HibernateUtil.getSession();

        return session.createCriteria(ModuleType.class) // <-- this is  ModuleTypeService.java line 50
                      .add(Example.create(example))
                      .addOrder(Order.asc("name"))
                      .list();
    }


Any help would be appreciated, thanks.


Top
 Profile  
 
 Post subject: left out the table definition
PostPosted: Fri Mar 30, 2007 5:18 pm 
Newbie

Joined: Fri Mar 30, 2007 4:43 pm
Posts: 3
Code:
CREATE TABLE [dbo].[ModuleType] (
   [ModuleTypeID] [int] IDENTITY (1, 1) NOT NULL ,
   [Name] [String50] NOT NULL ,
   [CreatedBy] [String50] NOT NULL ,
   [PluralName] [String50] NOT NULL ,
   [HasPublishDate] [bit] NULL ,
   [CreateDate] [datetime] NOT NULL ,
   [LastUpdatedBy] [String50] NOT NULL ,
   [LastUpdateDate] [datetime] NOT NULL
) ON [PRIMARY]
GO


Top
 Profile  
 
 Post subject: artifact of my parameterized marker interface
PostPosted: Fri Mar 30, 2007 5:54 pm 
Newbie

Joined: Fri Mar 30, 2007 4:43 pm
Posts: 3
my pojo also implements:
Code:
public interface ID<T extends Serializable> {
    T getId();
}


with T = java.lang.Integer

when hibernate inspects it however, it is picking up the the generic implementation of getId:
Code:
Serializable getId();
instead of
Code:
Integer getId();
which is in turn causing the conversion error, so my wild speculation about associations and serializable were way off base!


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