Hi,
I hava a table 'users' with column dept_id
(id of department in departments table)
This column is optional. That means
the operator doesn't have to assign inserted user to any
department.
If I have bean:
public class UserBean {
Integer
departmentId;
....
}
struts will make automatic conversion of type. So
departmentId will be set to 0, if I don't set any of department. That's a cheat,
because, I don't want to to have a
department with id equals to 0, it should be
NULL.
On the other hand, when I implement departmentId as
String, struts act correctly. But while inserting record to the database, I get
an error sth like this:
database column dept_id is type of bigint, inserted
value is type of varchar.
I have the solution: departmentId is type of
String, but for ibatis I have the other metod getDepartmentIdAsInteger which
return Integer or null if value is empty.
It works, but i don't like this.
Is there any cleaner solution for this. I looked
into jpetstore, but there were columns of type varchar. Rest of them was
mendatory.
I cannot use columns of type varchar as foreign
keys.
Usage:
....
VALUES(
#departmentId:INTEGER#, .... doesn't help if departmentId is String
Any ideas?
Darek
|
- Re: struts vs ibatis - Integer type Darek Dober
- Re: struts vs ibatis - Integer type Brandon Goodin
- Re: re: struts vs ibatis - Integer type Darek Dober
- Re: re: struts vs ibatis - Integer type Brandon Goodin
- Re: re: struts vs ibatis - Integer type Darek Dober
- Re: re: struts vs ibatis - Integer type Brandon Goodin
- Re: re: struts vs ibatis - Integer ... Rick Reumann
- Re: re: struts vs ibatis - Inte... Darek Dober
- Re: Re: struts vs ibatis - Integer type Lieven De Keyzer
- Re: Re: struts vs ibatis - Integer type Brandon Goodin
- Re: Re: struts vs ibatis - Integer type Lieven De Keyzer