These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Using Hibernate with Postgres XML column type
PostPosted: Thu Sep 04, 2008 11:09 am 
Newbie

Joined: Wed Nov 07, 2007 3:58 pm
Posts: 15
Hi,

I have a problem using hibernate with the postgres sql specific column type xml.

Code:
   @Column(columnDefinition="XML", name="document", nullable=false)//columnDefinition="LONGTEXT"
   private String xml = null;

   public String getXml() {
      return xml;
   }

   public void setXml(String xml) throws ConfigurationException {
      this.xml = xml;
      this.xmlDocument = XMLUtils.stringToXml(xml);   
   }


The generation of the database scheme works fine, but i get an exception caused by postgres when trying to insert my object as follows:

Code:
org.postgresql.util.PSQLException: ERROR: column "document" is of type xml but expression is of type character varying


OK - i know what this exception means and that postgres exspects an XML type as defined but i am trying to commit an varchar (String).

I have tried to use w3c.document instead but as exspected hibernate isn't able to map this.

So - does anybody know what kind of datatype to use in my classes that i am able to store something to a xml column in postgres ?
I know that postgres supports some String to XML mapping that will generate the right type, but is there a way to execute custom SQL while hibernate doing all his inserts ?

Hope that anybody can help

Cheers, Tobias


Top
 Profile  
 
 Post subject: UserType
PostPosted: Thu Sep 04, 2008 2:09 pm 
Newbie

Joined: Wed Nov 07, 2007 3:58 pm
Posts: 15
I will try to implement a XML UserType for Postgres / Hibernate.
But let me know if there is another solution out of the box.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.