title: Correct JPA Annotation for PostgreSQL's text type without Hibernate Annotations
body: <p>I'm developing an application using:</p>
  
  <ul>
  <li>Java 1.7</li>
  <li>JPA (included in javaee-api 7.0)</li>
  <li>Hibernate 4.3.8.Final</li>
  <li>PostgreSQL-JDBC 9.4-1200-jdbc41</li>
  <li>PostgreSQL 9.3.6</li>
  </ul>
  
  <p>And I would like to use the PostgreSQL text datatype for some String attributes. As far as I know, in JPA this should be the correct annotation, to use text in PostgreSQL:</p>
  
  <pre><code>@Entity
  public class Product{
      ...
      @Lob
      private String description;
      ....
  }
  </code></pre>
  
  <p>When I annotate my entity like this, I run into errors which look like this:
  <a href="http://www.shredzone.de/cilla/page/299/string-lobs-on-postgresql-with-hibernate-36.html" rel="noreferrer">http://www.shredzone.de/cilla/page/299/string-lobs-on-postgresql-with-hibernate-36.html</a></p>
  
  <p>In short: It seems that hibernate and jdbc go not hand in hand for clob/text-types.</p>
  
  <p>The solution described is working:</p>
  
  <pre><code>@Entity
  public class Product{
      ...
      @Lob
      @Type(type = "org.hibernate.type.TextType")
      private String description;
      ...
  }
  </code></pre>
  
  <p>But this has a significant downside: The source code needs hibernate at compile time, which should be unnecessary (That's one reason for using JPA in the first place).</p>
  
  <p>Another way is to use the column annotation like this:</p>
  
  <pre><code>@Entity
  public class Product{
      ...
      @Column(columnDefinition = "text")
      private String description;
      ...
  }
  </code></pre>
  
  <p>Which works nicely, BUT: 
  Now I'm stuck with databases which have a text type (and is also called text ;) ) and if another database will be used in the future the annotations can be overlooked easily. Thus the possible error can be hard to find, because the datatype is defined in a String and therefore can not be found before runtime.</p>
  
  <p>Is there a solution, which is so easy, I just don't see it? I'm very sure that I'm not the only one using JPA in combination with Hibernate and PostgreSQL. So I'm a little confused that I can't find more questions like this.</p>
  
  <p>Just to complete the question, the persistence.xml looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence version="1.0"
    xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
                          http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"&gt;
    &lt;persistence-unit name="entityManager"&gt;
      &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
      &lt;class&gt;com.app.model.Product&lt;/class&gt;
      &lt;properties&gt;
        &lt;property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" /&gt;
        &lt;property name="javax.persistence.jdbc.url"
          value="jdbc:postgresql://localhost:5432/awesomedb" /&gt;
        &lt;property name="javax.persistence.jdbc.user" value="usr" /&gt;
        &lt;property name="javax.persistence.jdbc.password" value="pwd" /&gt;
        &lt;property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" /&gt;
        &lt;property name="hibernate.jdbc.use_streams_for_binary" value="false" /&gt;
        &lt;property name="hibernate.hbm2ddl.auto" value="create-drop" /&gt;
        &lt;property name="show_sql" value="true" /&gt;
      &lt;/properties&gt;
    &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p><strong>UPDATE:</strong> </p>
  
  <ul>
  <li><p>This problem is more or less equivalent with this question, the picked answer is the second way to do it described in this question, which I don't like due to the hibernate runtime dependency:
  <a href="https://stackoverflow.com/questions/9158645/store-strings-of-arbitrary-length-in-postgresql">store strings of arbitrary length in Postgresql</a></p></li>
  <li><p>This seems to be kind of related to: <a href="https://hibernate.atlassian.net/browse/JPA-48" rel="noreferrer">https://hibernate.atlassian.net/browse/JPA-48</a></p></li>
  </ul>