our project needs support both oracle , postgres dbs. , there may more databases added list. need db agnostic hibernate configuration blob , clob datatypes.
while oracle working fine with:
@lob @column(name="column1") private string str; @lob @column(name="column2") private byte[] bytea;
postgres started complaining same.
org.springframework.orm.hibernate4.hibernatejdbcexception: jdbc exception on hibernate data access: sqlexception sql [insert table_name (table_type, table_id, table_content_bin, table_content_char) values (?, ?, ?, ?)]; sql state [0a000]; error code [0]; not insert: [com.project.entityclass]; nested exception org.hibernate.exception.genericjdbcexception: not insert: [com.project.entityclass]] caused by: org.hibernate.exception.genericjdbcexception: not insert: [com.project.entityclass] @ org.hibernate.exception.internal.standardsqlexceptionconverter.convert(standardsqlexceptionconverter.java:54) @ org.hibernate.engine.jdbc.spi.sqlexceptionhelper.convert(sqlexceptionhelper.java:126) @ org.hibernate.persister.entity.abstractentitypersister.insert(abstractentitypersister.java:3144) @ org.hibernate.persister.entity.abstractentitypersister.insert(abstractentitypersister.java:3581) @ org.hibernate.action.internal.entityinsertaction.execute(entityinsertaction.java:104) @ org.hibernate.engine.spi.actionqueue.executeactions(actionqueue.java:465) @ org.hibernate.engine.spi.actionqueue.executeactions(actionqueue.java:351) @ org.hibernate.event.internal.abstractflushingeventlistener.performexecutions(abstractflushingeventlistener.java:350) @ org.hibernate.event.internal.defaultflusheventlistener.onflush(defaultflusheventlistener.java:56) @ org.hibernate.internal.sessionimpl.flush(sessionimpl.java:1258) @ org.springframework.orm.hibernate4.springsessionsynchronization.beforecommit(springsessionsynchronization.java:104) ... 40 more caused by: java.sql.sqlfeaturenotsupportedexception: method org.postgresql.jdbc4.jdbc4preparedstatement.setcharacterstream(int, reader, long) not yet implemented. @ org.postgresql.driver.notimplemented(driver.java:670) @ org.postgresql.jdbc4.abstractjdbc4statement.setcharacterstream(abstractjdbc4statement.java:116) @ org.hibernate.type.descriptor.sql.clobtypedescriptor$4$1.dobind(clobtypedescriptor.java:124) @ org.hibernate.type.descriptor.sql.basicbinder.bind(basicbinder.java:90) @ org.hibernate.type.abstractstandardbasictype.nullsafeset(abstractstandardbasictype.java:286) @ org.hibernate.type.abstractstandardbasictype.nullsafeset(abstractstandardbasictype.java:281) @ org.hibernate.type.abstractsinglecolumnstandardbasictype.nullsafeset(abstractsinglecolumnstandardbasictype.java:56) @ org.hibernate.persister.entity.abstractentitypersister.dehydrate(abstractentitypersister.java:2857) @ org.hibernate.persister.entity.abstractentitypersister.insert(abstractentitypersister.java:3121) ... 48 more
researched , found people suggesting annotating @type( type = "org.hibernate.type.stringclobtype" )
, @type( type = "org.hibernate.type.binarytype" )
. both of hibernate annotations. however, intend use jpa annotations , need hibernate @ runtime, seems me unnecessary.
so question if there way handle blobs , clobs in generic way, not require branch codes different dbs , without adding hibernate specific annotations. also, not use hibernate table creation.
postgres version- 9.4-1201-jdbc41
oracle version - 12.1.0.1
hibernate version -4.3.10.final
since got no other answers here, thought post have done solve problem, may others.
since not creating tables hibernate, read somewhere hibernate/jpa able convert fields appropriate types without @lob
annotation. ex.- postgres text , oracle blob field of type byte[]
.
tried , worked both postgres , oracle. :)
Comments
Post a Comment