Closed GoogleCodeExporter closed 8 years ago
actually it is the long that is being set!
Original comment by i...@polevoy.org
on 9 Oct 2012 at 4:13
Original comment by i...@polevoy.org
on 9 Oct 2012 at 4:13
bad news, seems I cannot fix this. The reason is that the H2 and PostgreSQL
work as expected, but MySQL Driver converts the ID for a table to Java Long,
eve though it was declared in DML as INT.
The culprit is
http://code.google.com/p/activejdbc/source/browse/trunk/activejdbc/src/main/java
/org/javalite/activejdbc/DB.java#527
Converting this:
long id = rs.getLong(1);
to:
Object id = rs.getObject(1);
Fixes PostgreSQL and H2, but breaks MySQL. I have found no way to fix it for
all databases.
Test to recreate the problem:
public class Defect178Test extends ActiveJDBCTest {
@Test
public void shouldNotSetIdAsLongWhenCreatingRecord(){
deleteFromTable("addresses");
deleteFromTable("users");
User u = User.createIt("first_name", "John", "last_name", "Doe", "email", "john@doe.com");
User u1 = User.findFirst("first_name = ?", "John");
a(u.getId().getClass()).shouldBeEqual(u1.getId().getClass());
}
}
Original comment by i...@polevoy.org
on 9 Oct 2012 at 4:35
Original comment by i...@polevoy.org
on 9 Oct 2012 at 4:35
Original issue reported on code.google.com by
i...@polevoy.org
on 9 Oct 2012 at 3:34