java - Is there a easy way to map varchar2(1) ("1" or "0") to JPA boolean type -


i understand default map oracle data type number(1) jpa java boolean, not sure if there default cast varchar2(1) (it either '1' or '0') jpa java boolean? same way mapping number(1)?

not sure following idea ok, referred here:

public class people{      @externalvalues({"true=1", "false=0"})     @type(string.class)     private boolean weird;      ... } 

i using openjpa 2.2.0 here. thanks

you can use type casting in getter , setter methods , use string property datatype .

@column(length=1 ) private string string;    public boolean getstring() {     return boolean.valueof(string) ; }  public void setstring(boolean string) {     this.string =  (string) ? "1" : "0"; } 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -