Note that there are some explanatory texts on larger screens.

plurals
  1. POJPA Postgres insert Bit(4) with default value
    primarykey
    data
    text
    <p>I've got Postgres DB, Java with JPA 2.0 and eclipseLink.</p> <p>In my To object: </p> <pre><code> @Column(name = "mask") private Boolean mask; </code></pre> <p>IN DB: mask bit(4) DEFAULT B'1000'::"bit",</p> <p>When I want to presist the object:</p> <p>Caused by: org.postgresql.util.PSQLException: ERROR: column "mask" is of type bit but expression is of type boolean Hint: You will need to rewrite or cast the expression.</p> <p>I try in TO class: - Boolean - BitSet(4) - String - Integer - Char</p> <p>With BitSet I try, these: TO object: @Column(name = "mask") private BitSet mask;</p> <pre><code> public BitSet getMask() { BitSet work = new BitSet(4); work.set(0); if (mask == null){ return work; } return mask; } public void setMask(BitSet mask) { BitSet work = new BitSet(4); work.set(0); if (mask== null) { this.mask= work; } else { this.mask= mask; } } </code></pre> <p>How can i make it work? </p> <p>The boolean method is not good, store 1 bit. I search in google, lost of forums.</p> <p>After 5 hour of google search i found that: <a href="http://archives.postgresql.org/pgsql-bugs/2005-05/msg00014.php" rel="nofollow">http://archives.postgresql.org/pgsql-bugs/2005-05/msg00014.php</a></p> <p>Its about a postgres BUG:</p> <p>"Having a JDBC type called "BIT" which actually maps to a single boolean type is very confusing. If you assume that JDBC's BIT has <em>nothing</em> to do with the server type called "bit", and that it's just a coincidence that they have the same name, then things should be clearer."</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload