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

javascript - IndexedDB error: Uncaught DataCloneError: Failed to execute 'put' on 'IDBObjectStore': An object could not be cloned -

java - Unable to make sub reports with Jasper -

Integrity error when loading fixtures for Selenium testing in Django -