AnirbanDebnath
AnirbanDebnath

Reputation: 1043

Hibernate: Getting error after configuring Data Source in Weblogic "org.hibernate.exception.GenericJDBCException: could not update"

My application was running properly when I was configuring Hibernate.cfg.xml without any DataSource. I am deploying my application on Weblogic. But now I have configured it using a Data Source, (both in .cfg as well as Weblogic). Aster this suddenly I have started getting the exception when update on some table is happening. Without the DataSource its working fine.

This was the old config: (works fine)

<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
    <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:XE</property>
    <property name="hibernate.connection.username">username</property>
    <property name="hibernate.connection.password">password</property>
    <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
    <property name="org.hibernate.envers.track_entities_changed_in_revision">true</property>

Following is the new config: (throws exception)

<property name="connection.datasource">DataSourceTest</property>
    <property name="jndi.class">weblogic.jndi.WLInitialContextFactory</property>
    <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
    <property name="org.hibernate.envers.track_entities_changed_in_revision">true</property>
    <property name="show_sql">true</property>
    <!-- <property name="hibernate.connection.autocommit">true</property>  -->
    <property name="hibernate.hbm2ddl.auto">update</property>

I have made the similar cofiguration in Weblogic 12.1.3 also

But now its giving the following exception:

2016-07-20 14:45:02 INFO  AbstractBatchImpl:208 - HHH000010: On release of batch it still contained JDBC statements
2016-07-20 14:45:02 WARN  SqlExceptionHelper:144 - SQL Error: 17004, SQLState: 99999
2016-07-20 14:45:02 ERROR SqlExceptionHelper:146 - Invalid column type: 16
org.hibernate.exception.GenericJDBCException: could not update

All the Select and Insert queries are working just fine, but when the update happens, the above error is thrown.

My Lib folder contains the Hibernate Jar, JPA 2.1 jar.

Is it some issue with the configuration I am doing? All my mappings and columns etc seems to be fine. Any help would be appreciated.

Upvotes: 0

Views: 387

Answers (1)

Alexander Petrov
Alexander Petrov

Reputation: 9492

Hello the problem is coming from the fact that support of boolean in Oracle is either CHAR(1) or alternatively NUMBER(1). Which basically means that you will either have '1'-'0' or 'Y' -'N' combinations respectively. The problem is a conversion problem the JDBC driver needs to know how to convert your boolean into the CHAR(1)/NUMBER(1)

You can try the following: 1. Set your dialect to org.hibernate.dialect.Oracle10gDialect

Alternatively you can try to convert the Number(1)/Char(1):

@org.hibernate.annotations.Type(type="true_false") @NotNull boolean value;

or

@org.hibernate.annotations.Type(type="yes_no") @NotNull boolean value;

Upvotes: 1

Related Questions