Permalink
Browse files

HHH-4635 Oracle ORA-24816 inserting and updating data for entities

containg LOB attributes
  • Loading branch information...
1 parent 6a5bd55 commit 9f720b2d73213000eb8ef3b0dccf0c7a3044feea brmeyer committed Sep 18, 2012
@@ -0,0 +1,60 @@
+package org.hibernate.test.annotations.lob.hhh4635;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.dialect.Oracle8iDialect;
+import org.hibernate.testing.RequiresDialect;
+import org.hibernate.testing.TestForIssue;
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+import org.jboss.logging.Logger;
+import org.junit.Test;
+
+/**
+ * To reproduce this issue, Oracle MUST use a multi-byte character set (UTF-8)!
+ *
+ * @author Brett Meyer
+ */
+@RequiresDialect( Oracle8iDialect.class )
+@TestForIssue( jiraKey = "HHH-4635" )
+public class LobTest extends BaseCoreFunctionalTestCase {
+
+ private static final Logger LOG = Logger.getLogger( LobTest.class );
+
+ @Test
+ public void hibernateTest() {
+ printConfig();
+
+ Session session = openSession();
+ session.beginTransaction();
+ LobTestEntity entity = new LobTestEntity();
+ entity.setId(1L);
+ entity.setLobValue(session.getLobHelper().createBlob(new byte[9999]));
+ entity.setQwerty(randomString(4000));
+ session.save(entity);
+ session.getTransaction().commit();
+ }
+
+ @Override
+ protected Class[] getAnnotatedClasses() {
+ return new Class[] { LobTestEntity.class };
+ }
+
+ private String randomString( int count ) {
+ StringBuilder buffer = new StringBuilder(count);
+ for( int i = 0; i < count; i++ ) {
+ buffer.append( 'a' );
+ }
+ return buffer.toString();
+ }
+
+ private void printConfig() {
+ String sql = "select value from V$NLS_PARAMETERS where parameter = 'NLS_CHARACTERSET'";
+
+ Session session = openSession();
+ session.beginTransaction();
+ Query query = session.createSQLQuery( sql );
+
+ String s = (String) query.uniqueResult();
+ LOG.debug( "Using Oracle charset " + s );
+ }
+}
@@ -0,0 +1,46 @@
+package org.hibernate.test.annotations.lob.hhh4635;
+
+import java.sql.Blob;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table( name = "lob_test" )
+public class LobTestEntity {
+
+ @Id
+ private Long id;
+
+ private Blob lobValue;
+
+ @Column( name = "qwerty", length = 4000 )
+ private String qwerty;
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setLobValue(Blob lobValue) {
+ this.lobValue = lobValue;
+ }
+
+ public Blob getLobValue() {
+ return lobValue;
+ }
+
+ public void setQwerty(String qwerty) {
+ this.qwerty = qwerty;
+ }
+
+ public String getQwerty() {
+ return qwerty;
+ }
+
+}

0 comments on commit 9f720b2

Please sign in to comment.