Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6863005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:43:48+00:00 2026-05-27T02:43:48+00:00

I have two transactions managers defined in applicationContext, referencing two completely different sessionFactories. I

  • 0

I have two transactions managers defined in applicationContext, referencing two completely different sessionFactories. I am attempting to use annotations with one of the transactionmanagers however it seems to be applying all annotations to both transaction managers.

The new db I am migrating to has <property name="hbm2ddl.auto">create</property> and the other which I am migrating from has <property name="hbm2ddl.auto">validate</property>

I have annotated my new domain objects with @Entity hibernate is attempting to validate these classes on the legacy database, which I thought I had set up to ignore annotations (by not specifying annotations). Here are the relevant snippets of appContext:

    <tx:annotation-driven transaction-manager="transactionManager1" />
    <context:property-placeholder location="file:${catalina.home}/conf/database.properties" ignore-unresolvable="true"/>

    <bean id="sessionFactory1" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" p:dataSource-ref="dataSource1" p:configLocation="WEB-INF/classes/hibernate.cfg.xml" p:packagesToScan="com.mycompany"/>

<!-- Declare a datasource that has pooling capabilities-->   
<bean id="dataSource1" class="com.mchange.v2.c3p0.ComboPooledDataSource" 
p:driverClass="${app.driverClassName}" p:jdbcUrl="${app.url}" 
p:user="${app.username}" p:password="${app.password}"

    <!-- Declare a transaction manager-->
    <bean id="transactionManager1" class="org.springframework.orm.hibernate3.HibernateTransactionManager" p:sessionFactory-ref="sessionFactory1" />

and the legacy db in same appContext :

<bean id="sessionFactory2" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"    p:dataSource-ref="dataSource2" p:configLocation="WEB-INF/classes/hibernateTraveller.cfg.xml" p:packagesToScan="com.mycompany"/>

<!-- Declare a datasource that has pooling capabilities-->   
<bean id="dataSource2" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close" 
p:driverClass="${app2.driverClassName}" p:jdbcUrl="${app2.url}" 
p:user="${app2.username}" p:password="${app2.password}"

<!-- Declare a transaction manager-->
<bean id="transactionManager2" class="org.springframework.orm.hibernate3.HibernateTransactionManager" 
            p:sessionFactory-ref="sessionFactoryTraveller"> 
<qualifier value="legacyDB"/>
</bean>

any pointers ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:43:48+00:00Added an answer on May 27, 2026 at 2:43 am

    You should use LocalSessionFactoryBean instead of AnnotationSessionFactoryBean for your legacy database that does not use annotations. The whole purpose of the AnnotationSessionFactoryBean is to use annotations. If you don’t want to use annotations, LocalSessionFactoryBean is the way to go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my spring configuration I have two transaction managers defined for two different databases.
Lets say I have two tables, one for transactions, and another table who's primary
I have two tables: one contains employees information and another is transactions (sales) information
I have to maintain transactions between two different databases. I need to rollback if
One of the classical reasons we have a database deadlock is when two transactions
I have set up transactional replication between two SQL Servers on different ends of
I have a wicket page , which contains two Spring-managed beans , one is
So I have two methods. Method one adds a row to my database. Method
I have two databases: Transactions and Customer List I want to populate the customer
I have a deadlock problem with two transactions that do not access any common

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.