Hi,
I've got a problem when I recover the PK of an object in two different ways.
I've got the following method getId() for this object:
public Long getId() {
return (getObjectId() != null && !getObjectId().isTemporary())
?
(Long)getObjectId().getIdSnapshot().get(ID_PK_COLUMN)
: null;
}
The PK for this table is a BIGINT(20), in my MYSQL database.
My problem arises when I call this method in this sequence:
Command cmd = new Command(....);
db.commit(); //A new row is created in database.
Then I want to recover the PK calling:
cmd.getId();
but a CastClassException happens, because it's yielded a Integer instead
of a Long.
The solution would be to change the object type to Integer, but...
If I get the object by a select, for example:
Command cmd = Command.getByNumSeq(...); //That is a select query.
I can get the PK by cmd.getId() without any problem and a Long value is
returned.
Is it created the PK as an Integer always?
Is there anyway to avoid it? or should I create all the PK as INTEGER
instead of BIGINT?
Any hint to my problem?
Thanks, in advance
Jorge Sopena
This archive was generated by hypermail 2.0.0 : Wed Apr 28 2004 - 12:42:09 EDT