-->
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.  [ 1 post ] 
Author Message
 Post subject: hibernate+jpa+postgresql: no dialet mapping
PostPosted: Tue May 01, 2012 6:43 pm 
Newbie

Joined: Tue May 01, 2012 6:35 pm
Posts: 1
i used a native query to call a function in my postgresql database, code is like this:
Code:
String query = "select details,rec_xml[1] from f_get_reccomendations(\'/ma:recommendations/ma:recommendation/name/text()\') ORDER BY id DESC LIMIT 1;";
Query q = em.createNativeQuery(query);
return q.getResultList();


the function defined as:
Code:
CREATE OR REPLACE FUNCTION f_get_reccomendations (
  IN  xpath    varchar(128),
  OUT id       int,
  OUT recs_num int,
  OUT details  varchar(25),
  OUT d_stamp  timestamp,
  OUT rec_xml  xml[]
) RETURNS SETOF RECORD AS
$$
select id, recs_num, details, d_stamp, xpath($1, recs,
          array [
                  array['xs','http://www.w3.org/2001/XMLSchema'],
                  array['ma','http://schemas.medio.com/analytics/1.0']
                ]
          ) from recommendations;
$$
LANGUAGE SQL;


when ran from the psql, it worked, but when i run in the code, it threw me error: No Dialect mapping for JDBC type: 2009. my guess is the rec_xml is defined as xml[] type that hibernate could not understand, so i added the following code to extend the Dialect:

Code:
public class RelePostgreSQLDialect extends PostgreSQLDialect {

   public RelePostgreSQLDialect() {
      super();
      registerColumnType(Types.VARCHAR, "xml");
   }
}


and specified the dialect in persistem.xml:
Code:
<persistence-unit name="dashboard-postgres-dev" transaction-type="RESOURCE_LOCAL">
..
<property name="hibernate.dialect" value="com.dyihi.eval.rdb.RelePostgreSQLDialect" />
...
  </persistence-unit>


but still i got the same error, please help!


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

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.