-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate 2, postgresql dialect and boolean types problem...
PostPosted: Tue Jan 08, 2008 9:26 am 
Beginner
Beginner

Joined: Thu Sep 01, 2005 7:43 am
Posts: 31
Location: León (Spain)
Hibernate version: 2.0
Name and version of the database you are using: PostgreSQL 8.2

We're having some issues in an Oracle 9i to PostgreSQL 8.2 transition. The project was done externally and has some libraries for which we lack sources... (that's why we don't have code, stacktraces and such)

Problems arise at the point of session updates, and we think they're due to boolean types. Database structure was unmodified, and boolean types are stored in numeric format (1 or 0, as Oracle treats them). As sources are mostly unmodified, postgresql dialect tries to use "bool" types in sqls and database expects numbers. We've tried to extend postgres dialect to change some values, but hibernate2 isn't as flexible as hib3 and the only option was to try a "registerColumnType". Code as follows:

public class SpecificPostgreSQLDialect extends PostgreSQLDialect {

public SpecificPostgreSQLDialect() {
super();
System.out.println("Instanced...");

registerColumnType( Types.BIT, "int2" );

getDefaultProperties().setPropertyEnvironment.QUERY_SUBSTITUTIONS, "true 1,false 0");
getDefaultProperties().setProperty(Environment.SHOW_SQL, "true");
}

}

This didn't work. Same symptoms.

Has anyone done a similar transition? How did you tackle the bool problem? Other workaround could involve a defined UserType for this boolean to int mapping. Any suggestions?

Thanks.

_________________
Please rate...

Expert on Hibernate errors... I've had them all... :P


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 08, 2008 2:13 pm 
Beginner
Beginner

Joined: Thu Sep 01, 2005 7:43 am
Posts: 31
Location: León (Spain)
Just for clarification...

Property:
private Boolean indActivo;


Property mapping:
<property
name="indActivo"
type="boolean"
column="IND_ACTIVO"
not-null="true"
length="1"
>
</property>

Stack trace:

Caused by: org.postgresql.util.PSQLException: ERROR: column "ind_activo" is of type numeric but expression is of type boolean
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse QueryExecutorImpl.java:1559)
at org.postgresql.core.v3.QueryExecutorImpl.processResults QueryExecutorImpl.java:1327)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:193)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:351)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:305)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:462)
... 8 more


The generated SQL is binding 'true' to that parameter.
Any ideas?

_________________
Please rate...

Expert on Hibernate errors... I've had them all... :P


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 03, 2008 11:30 am 
Newbie

Joined: Wed Dec 03, 2008 11:28 am
Posts: 1
Hi

Have you found any solution to this?
I have a similar problem with Hibernate3 and some EnterpriseDB tables, imported from Oracle 10g.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 03, 2009 4:29 am 
Newbie

Joined: Tue Jun 26, 2007 9:22 am
Posts: 3
Did you solve the problem ??
If yes post the solution please.......
thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.