IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Spring Java Discussion :

[Hibernate] Utilisation de deux session différente


Sujet :

Spring Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau membre du Club
    Inscrit en
    Janvier 2009
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Janvier 2009
    Messages : 7
    Par défaut [Hibernate] Utilisation de deux session différente
    Bonjour à tous,

    je voudrais mettre deux dataSources dans mon fichier de configuration Spring, je voudrais savoir si c'est possible si oui comment pourrais je le faire.

    merci d'avance.

  2. #2
    Membre éprouvé
    Avatar de David Gimelle
    Profil pro
    Développeur Java
    Inscrit en
    Janvier 2007
    Messages
    79
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Janvier 2007
    Messages : 79
    Par défaut
    suffit de declarer 2 dataSources avec des noms differents dans les fichiers de conf de spring.

    David Gimelle
    Developpeur J2ee
    blog: Http://getj2ee.over-blog.com

  3. #3
    Nouveau membre du Club
    Inscrit en
    Janvier 2009
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Janvier 2009
    Messages : 7
    Par défaut
    et dans le sessionFactory je dois mettre mes deux data sources? pourrais tu me donner un exemple.

  4. #4
    Membre éprouvé
    Avatar de David Gimelle
    Profil pro
    Développeur Java
    Inscrit en
    Janvier 2007
    Messages
    79
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Janvier 2007
    Messages : 79
    Par défaut
    tu surement va devoir definir 2 sessionFactory.

    Est-ce que tu peux montrer ton fichier de config ?

    David Gimelle
    Developpeur J2ee
    blog: Http://getj2ee.over-blog.com

  5. #5
    Nouveau membre du Club
    Inscrit en
    Janvier 2009
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Janvier 2009
    Messages : 7
    Par défaut
    oui biensur:

    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- Application context for AlimCpt testing -->
     
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:aop="http://www.springframework.org/schema/aop"
    	xmlns:tx="http://www.springframework.org/schema/tx"
    	xsi:schemaLocation="
    	   <a href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a> <a href="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd" target="_blank">http://www.springframework.org/schem...-beans-2.5.xsd</a>
    	   <a href="http://www.springframework.org/schema/tx" target="_blank">http://www.springframework.org/schema/tx</a> <a href="http://www.springframework.org/schema/tx/spring-tx-2.5.xsd" target="_blank">http://www.springframework.org/schem...ing-tx-2.5.xsd</a>
    	   <a href="http://www.springframework.org/schema/aop" target="_blank">http://www.springframework.org/schema/aop</a> http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
     
     
    	<bean id="anetoVueCotisationEncaissement"
    		class="com.npfo.comptabilite.business.anetovuecotisationencaissement.AnetoVueCotisationEncaissementImpl">
    		<property name="anetoVueCotisationEncaissementDAO">
    			<ref bean="anetoVueCotisationEncaissementDAO" />
    		</property>
    	</bean>
     
    	<bean id="anetoVueCotisationEncaissementDAO"
    		class="com.npfo.comptabilite.business.anetovuecotisationencaissement.AnetoVueCotisationEncaissementDAOImpl">
    		<property name="dataSource">
    			<ref bean="dataSource" />
    		</property>
    	</bean>
     
    	<bean id="dataSource"
    		class="org.apache.commons.dbcp.BasicDataSource"
    		destroy-method="close">
    		<property name="driverClassName"
    			value="oracle.jdbc.driver.OracleDriver" />
    		<property name="url"
    			value="jdbc:oracle:thin:@frtlr210.soltim:1521:ANETO51" />
    		<property name="username" value="I4UD17_USER" />
    		<property name="password" value="I4UD17_USER" />
    	</bean>
     
     
     
    	<bean id="txManager"
    		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    		<property name="sessionFactory" ref="sessionFactory" />
    	</bean>
     
    	<bean id="sessionFactory"
    		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name="dataSource">
    			<ref bean="dataSource" />
    		</property>
    		<property name="configLocation">
    			<value>classpath:hibernate.cfg.xml</value>
    		</property>
    	</bean>
     
    	<!-- enable the configuration of transactional behavior based on annotations -->
    	<!--tx:annotation-driven transaction-manager="txManager"/-->
    </beans>

  6. #6
    Nouveau membre du Club
    Inscrit en
    Janvier 2009
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Janvier 2009
    Messages : 7
    Par défaut
    j'ai essayé ce que tu m'as dis et ça me donne toujours une exception, voici mon nouveau fichier de conf spring:
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- Application context for AlimCpt testing -->
     
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:aop="http://www.springframework.org/schema/aop"
    	xmlns:tx="http://www.springframework.org/schema/tx"
    	xsi:schemaLocation="
    	   <a href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a> <a href="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd" target="_blank">http://www.springframework.org/schem...-beans-2.5.xsd</a>
    	   <a href="http://www.springframework.org/schema/tx" target="_blank">http://www.springframework.org/schema/tx</a> <a href="http://www.springframework.org/schema/tx/spring-tx-2.5.xsd" target="_blank">http://www.springframework.org/schem...ing-tx-2.5.xsd</a>
    	   <a href="http://www.springframework.org/schema/aop" target="_blank">http://www.springframework.org/schema/aop</a> http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
     
     
    	<bean id="anetoVueCotisationEncaissement"
    		class="com.npfo.comptabilite.business.anetovuecotisationencaissement.AnetoVueCotisationEncaissementImpl">
    		<property name="anetoVueCotisationEncaissementDAO">
    			<ref bean="anetoVueCotisationEncaissementDAO" />
    		</property>
    	</bean>
     
    	<bean id="anetoVueCotisationEncaissementDAO"
    		class="com.npfo.comptabilite.business.anetovuecotisationencaissement.AnetoVueCotisationEncaissementDAOImpl">
    		<property name="dataSource">
    			<ref bean="dataSource" />
    		</property>
    	</bean>
     
    	<bean id="dataSource"
    		class="org.apache.commons.dbcp.BasicDataSource"
    		destroy-method="close">
    		<property name="driverClassName"
    			value="oracle.jdbc.driver.OracleDriver" />
    		<property name="url"
    			value="jdbc:oracle:thin:@frtlr210.soltim:1521:ANETO51" />
    		<property name="username" value="I4UD17_USER" />
    		<property name="password" value="I4UD17_USER" />
    	</bean>
     
    /******************AnetoVueComptablesCommun*****************/
    	<bean id="anetovuescomptablescommun"
    		class="com.npfo.comptabilite.business.common.anetovuescomptablescommun.AnetoVuesComptablesCommunImpl">
    		<property name="AnetoVuesComptablesCommunDao">
    			<ref bean="AnetoVuesComptablesCommunDao" />
    		</property>
    	</bean>
     
    	<bean id="AnetoVuesComptablesCommunDao"
    		class="com.npfo.comptabilite.business.common.anetovuescomptablescommun.AnetoVuesComptablesCommunDaoImpl">
    		<property name="dataSourceComCom">
    			<ref bean="dataSourceComCom" />
    		</property>
    	</bean>
     
    	<bean id="dataSourceComCom"
    		class="org.apache.commons.dbcp.BasicDataSource"
    		destroy-method="close">
    		<property name="driverClassName"
    			value="oracle.jdbc.driver.OracleDriver" />
    		<property name="url"
    			value="jdbc:oracle:thin:@frtlr210.soltim:1521:ANETO51" />
    		<property name="username" value="I4UD17_OWNER" />
    		<property name="password" value="I4UD173403" />
    	</bean>
     
    	<bean id="txManager"
    		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    		<property name="sessionFactory" ref="sessionFactory" />
    	</bean>
     
    	<bean id="sessionFactory"
    		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name="dataSource">
    			<ref bean="dataSource" />
    		</property>
    		<property name="configLocation">
    			<value>classpath:hibernate.cfg.xml</value>
    		</property>
    	</bean>
     
    	<bean id="sessionFactory"
    		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name="dataSourceComCom">
    			<ref bean="dataSourceComCom" />
    		</property>
    		<property name="configLocation">
    			<value>classpath:hibernate.cfg.xml</value>
    		</property>
    	</bean>
     
    	<!-- enable the configuration of transactional behavior based on annotations -->
    	<!--tx:annotation-driven transaction-manager="txManager"/-->
    </beans>

Discussions similaires

  1. Utilisation de deux bibliothèques différentes pour le cryptage RSA --> impossible ?
    Par Djobird dans le forum Algorithmes et structures de données
    Réponses: 2
    Dernier message: 26/01/2011, 17h25
  2. Réponses: 2
    Dernier message: 10/05/2010, 09h41
  3. Utilisation de deux sessions
    Par gazelle dans le forum Langage
    Réponses: 2
    Dernier message: 21/02/2008, 16h35
  4. Réponses: 5
    Dernier message: 23/03/2007, 13h22
  5. Réponses: 8
    Dernier message: 13/03/2006, 17h37

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo