Hello,
I have a puzzling message from Hibernate. On a findBy method it tries to use a Long instead of an integer.
I didn't specify any Long in the domain class, nor in the mapping, nor in the test..
Any clue ?
Thanks
Stephane
Code:
Hibernate:
insert
into
contact_referer
(id, version, list_order, description)
values
(null, ?, ?, ?)
08:04:28,460 DEBUG IntegerType:133 - binding '0' to parameter: 1
08:04:28,461 DEBUG IntegerType:133 - binding '2' to parameter: 2
08:04:28,461 DEBUG TextType:133 - binding 'Google' to parameter: 3
Hibernate:
call identity()
Hibernate:
insert
into
contact_referer
(id, version, list_order, description)
values
(null, ?, ?, ?)
08:04:28,467 DEBUG IntegerType:133 - binding '0' to parameter: 1
08:04:28,467 DEBUG IntegerType:133 - binding '1' to parameter: 2
08:04:28,467 DEBUG TextType:133 - binding 'Facebook' to parameter: 3
Hibernate:
call identity()
Hibernate:
select
this_.id as id94_0_,
this_.version as version94_0_,
this_.list_order as list3_94_0_,
this_.description as descript4_94_0_
from
contact_referer this_
where
this_.list_order>?
order by
this_.list_order asc
08:04:28,474 DEBUG IntegerType:133 - binding '0' to parameter: 1
08:04:28,475 INFO IntegerType:140 - could not bind value '0' to parameter: 1; java.lang.Long cannot be cast to java.lang.Integer
The test that fails:
Code:
@Test
public void testFindNext() {
contactReferer0 = contactRefererDao.makePersistent(contactReferer0);
contactReferer1 = contactRefererDao.makePersistent(contactReferer1);
ContactReferer contactReferer = contactRefererDao.findNextByListOrder(0);
assertEquals(1, contactReferer.getListOrder());
assertEquals("Facebook", contactReferer.getDescription());
contactReferer = contactRefererDao.findNextByListOrder(1);
assertEquals(2, contactReferer.getListOrder());
assertEquals("Google", contactReferer.getDescription());
}
The mapping file:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Apr 18, 2010 1:03:51 PM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
<class name="core.domain.ContactReferer" table="contact_referer">
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="identity" />
</id>
<version name="version" type="int">
<column name="version" not-null="true" />
</version>
<property name="listOrder" type="int">
<column name="list_order" not-null="true" />
</property>
<property name="description" type="text">
<column name="description" length="65535" not-null="false" />
</property>
</class>
</hibernate-mapping>
The domain class:
Code:
public class ContactReferer implements java.io.Serializable {
private Integer id;
private int version;
private int listOrder;
private String description;
public ContactReferer() {
}
public ContactReferer(int listOrder, String description) {
this.listOrder = listOrder;
this.description = description;
}
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public int getVersion() {
return this.version;
}
public void setVersion(int version) {
this.version = version;
}
public int getListOrder() {
return this.listOrder;
}
public void setListOrder(int listOrder) {
this.listOrder = listOrder;
}
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
}