Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.1
Name and version of the database you are using: Ingres
Hi!
I've got a table:
Code:
CREATE TABLE phone (
id INTEGER NOT NULL,
number VARCHAR(20) NOT NULL,
mobile CHAR(1) NOT NULL CHECK(mobile = 'y' OR mobile = 'n'),
private CHAR(1) NOT NULL CHECK(private = 'y' OR private = 'n'),
fax CHAR(1) NOT NULL CHECK(fax = 'y' OR fax = 'n'),
PRIMARY KEY(id)
);
From the hibernate tools I got this POJO:
Code:
@Entity
@Table(name = "phone", schema = "ingres", uniqueConstraints = {})
public class UsermgrPhone implements java.io.Serializable
{
...
private Integer id;
private String number;
private Character mobile;
private Character private_;
private Character fax;
...
@Column(name = "number", unique = false, nullable = false, insertable = true, updatable = true, length = 20)
public String getNumber()
{
return this.number;
}
@Column(name = "mobile", unique = false, nullable = false, insertable = true, updatable = true, length = 1)
public Character getMobile()
{
return this.mobile;
}
...
}
Now, how can I tell Hibernate that this Character is a Boolean. Thus I'll get this POJO:
Code:
@Column(name = "mobile", unique = false, nullable = false, insertable = true, updatable = true, length = 1)
public Boolean isMobile()
{
return ...;
}
That means I want to map the Character to a Boolean. It doesn't matter how Hibernate will handle this case, but I want to use only the "Boolean" method,
because I don't want to write:
Code:
if (getMobile() == 'y') ...
Thank you!