-->
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: Problems due to hibernate-core 4.1.0 migration
PostPosted: Fri Feb 24, 2012 1:38 pm 
Newbie

Joined: Fri Feb 24, 2012 1:28 pm
Posts: 1
Hello, i've some problems with hibernate-core migration.

I'm using Spring 3.1.1.RELEASE, Hibernate-core 4.1.0 and Hsqldb 2.2.8

My SessionFactory building :

Code:
      final Properties props = new Properties();
      props.put("hibernate.connection.shutdown", "true");
      props.put("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver");
      props.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
      props.put("hibernate.hbm2ddl.auto", "create-drop");
      props.put("hibernate.current_session_context_class",
            "org.springframework.orm.hibernate4.SpringSessionContext");
      props.put("hibernate.show_sql", "true");

      final DatasourceConnectionProviderImpl service = new DatasourceConnectionProviderImpl();
      service.setDataSource(new SingleConnectionDataSource("jdbc:hsqldb:mem:test", "sa", "", true));
      service.configure(props);
      final ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().addService(
            ConnectionProvider.class, service).applySettings(props).buildServiceRegistry();

      final MetadataSources metadataSources = new MetadataSources(serviceRegistry);
      metadataSources.addResource("myPackage/ObjectToTest.hbm.xml");
      final Metadata metadata = metadataSources.buildMetadata();
      sessionFactory = metadata.buildSessionFactory();


My test :
Code:
   @org.junit.Test
   public void testPersist() {

      new TransactionTemplate(new HibernateTransactionManager(sessionFactory)).execute(new TransactionCallbackWithoutResult() {

         @Override
         protected void doInTransactionWithoutResult(final TransactionStatus status) {
            final Session currentSession = sessionFactory.getCurrentSession();
            final ObjectToTest object = new ObjectToTest("myText");
            currentSession.persist(object);
         }
      });

   }


My mapping :

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>


<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

<hibernate-mapping default-lazy="false"
   xmlns="http://www.hibernate.org/xsd/hibernate-mapping"
   xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping hibernate-mapping-4.0.xsd"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

   <class name="myPackage.ObjectToTest">
      <id name="id">
         <generator class="native" />
      </id>
      <property name="text" />
   </class>

</hibernate-mapping>




With this configuration i have :

Code:
Caused by: java.sql.SQLIntegrityConstraintViolationException: integrity constraint violation: NOT NULL check constraint; SYS_CT_10025 table: "ObjectToTest" column: "id"
   at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
   at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
   at org.hsqldb.jdbc.JDBCPreparedStatement.fetchResult(Unknown Source)
   at org.hsqldb.jdbc.JDBCPreparedStatement.executeUpdate(Unknown Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


I saw that native is deprecated but i don't know how to replace it

Any ideas ?

Thanks


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.