Is there a simple way to trim() Strings as loaded from database into Entity? [message #381278] |
Tue, 09 September 2008 12:30  |
Eclipse User |
|
|
|
I am working with a data base of log enteries. The String fields are
described at 255 fixed length. Some are empty. Most have only a few
meaningful characters at the front (user, IP adress, etc).
The entity being returned is populated with the full 255 character, mostly
blank.
Is there anyway to trim() the String fields as they are loaded into the
entity?
The reason I want to do this is that the program will be running queries
which return Lists of the entities. Each entity has several untrimmed
fields with mostly blanks and the querry returns several hundred records.
@Column (name="FOO")
String foo;
..
..
public String getFoo() {
return foo.trim();
}
Yes, the value returned is trimmed but entity.foo is 255 characters,
mostly blanks.
public void setFoo( String foo) {
this.foo = foo.trim();
}
Doesn't help, setFoo isn't called when the entity is made.
@ReadTransformer(method="trimFoo)
public String trimFoo(Record rec, Session ses) {
return ((String)rec.get("FOO")).trim();
}
might work but it seems like a lot of work.
Are there any other ways to do this?
Thanks!
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07153 seconds