I'm working with an Oracle 9i database. There are several columns with type CHAR and a specific length.
My problem is that when JPA tries to bind a parameter, it doesn't know to pad with spaces to meet the full length.
I have an entity named UserGroup with a column like the following:
@Id
@Column(name = "USERID", nullable = false, length=32)
private String userid;
So a query like this:
entityManager.createQuery("SELECT u FROM UserGroup u WHERE u.userid like :user").setParameter("user", user).getSingleResult();
fails unless I do the following:
entityManager.createQuery("SELECT u FROM UserGroup u WHERE u.userid [b]like[/b] :user").setParameter("user", [b]user + "%"[/b]).getSingleResult();
. . . and then it does the right thing.
BUT, if there is any kind of relationship involved with another column of type CHAR, it doesn't find it, and I don't have a nifty little workaround like the one above.
HELP! I'm starting to think of abandoning JPA if I can't figure out how to make it work with these columns, because it is a vendor database and I cannot change the schema to convert the columns to VARCHAR.
[Message sent by forum member 'marcusocasey' (marcusocasey)]
http://forums.java.net/jive/thread.jspa?messageID=253258