Announcement Announcement Module
Collapse
No announcement yet.
HibernateJpaDialect coupled to SessionFactoryUtils of Hibernate 3 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HibernateJpaDialect coupled to SessionFactoryUtils of Hibernate 3

    Hi,
    I'm using Hibernate 4.1 - it seems that the exception translation happening on the HibernateJpaDialect is different from the one happening in HibernateExceptionTranslator - mainly that the HibernateJPADialect is coupled to the 3.x version of Hibernate.
    First, should the execption translation logic from here (in HibernateJPADialect) be improved to make use of the existing HibernateExceptionTranslator logic? That way it could choose the right implementation - between Hibernate 3.x and 4.x.
    Second, if not, should a HibernateJPADialect in the "org.springframework.orm.hibernate4" package exist, so that it can be explicitly used?
    Am I missing some vital piece of the configuration or is this by design?
    Thanks.
    Eugen.

  • #2
    Is there any way to bump this thread up? I have the same question myself

    Comment


    • #3
      Hi,
      could you give us more information about this issue?
      Are you having an exception that is not handled properly, or are you having an exception when your code should be running fine?
      Also, please include a code sample (and a stacktrace) if you think it can be of any help.

      Comment


      • #4
        I have noticed this too. Not sure if it is intended to use hibernate3.SessionFactoryUtils when there is in fact a SessionFactoryUtils in hibernate4 package also.

        This error is expected, I have a onetoone relationship in my database which is not satisfied on one side.

        my stack trace is as follows:

        Code:
        org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:690)
        	org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:104)
        	org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:403)
        	org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:58)
        Here is a snippet from my context xml file.

        Code:
        	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        		<property name="driverClassName" value="com.mysql.jdbc.Driver" />
        		<property name="url" value="${db.url}" />
        		<property name="username" value="${db.username}" />
        		<property name="password" value="${db.password}" />
        	</bean>
        	
        	<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" />
        
        	<!-- transaction manager for use with a single JPA EntityManagerFactory for transactional data access to a single datasource -->
        	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        		 <property name="entityManagerFactory" ref="entityManagerFactory" /> 
        	</bean>
        	
        	<bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
        
        	<bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="entityManagerFactory">
        		<property name="dataSource" ref="dataSource" />
        		<property name="persistenceProviderClass" value="org.hibernate.ejb.HibernatePersistence" />
        		<property name="jpaVendorAdapter">
        			<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
        		</property>
        		<property name="jpaProperties">
        			<props>
        				<prop key="hibernate.dialect">${hibernate.dialect}</prop>
        				<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
        				<prop key="hibernate.ejb.naming_strategy">${hibernate.ejb.naming_strategy}</prop>
        				<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
        			</props>
        		</property>
        		<property name="packagesToScan">
        			<list>
        				<value>${entitymanager.packages.to.scan}</value>
        			</list>
        		</property>
        	</bean>

        Comment

        Working...
        X