0 Replies Latest reply on Oct 31, 2007 12:32 PM by Manuel Fidalgo

    Seam with 2 datasources (Postgres+MySQL)

    Manuel Fidalgo Newbie

      Hello, Im working with SEAM 1.2.1 and I have two datasources: one is from a Postgres database (and works fine) and the other one is for a MySQL database ('WP7Datasource', which doesn't work).
      The problem is that when I start JBoss i get this error:

      16:58:20,968 INFO [SessionFactoryImpl] building session factory
      17:08:39,718 WARN [ServiceController] Problem starting service persistence.units:ear=medieq-aqua.ear,jar=medieq-aqua.jar,unitName=WP7Datasource
      javax.persistence.PersistenceException: org.hibernate.MappingException: could not instantiate id generator
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:695)
      at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:127)
      at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:264)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      ...

      Caused by: org.hibernate.MappingException: could not instantiate id generator
      at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:98)
      at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:152)
      at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:192)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1218)
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:688)
      ... 147 more
      Caused by: org.hibernate.MappingException: Dialect does not support sequences
      at org.hibernate.dialect.Dialect.getSequenceNextValString(Dialect.java:570)
      at org.hibernate.id.SequenceGenerator.configure(SequenceGenerator.java:65)
      at org.hibernate.id.SequenceHiLoGenerator.configure(SequenceHiLoGenerator.java:43)
      at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:94)

      ....


      the datasources are defined here:

      <?xml version="1.0" encoding="UTF-8"?>
      <datasources>
       <local-tx-datasource>
       <jndi-name>medieqDatasource</jndi-name>
       <connection-url>
       jdbc:postgresql://localhost:5432/medieqdev
       </connection-url>
       <driver-class>org.postgresql.Driver</driver-class>
       <user-name>****</user-name>
       <password>****</password>
       <connection-property name="char.encoding">
       UTF-8
       </connection-property>
       <transaction-isolation>
       TRANSACTION_READ_COMMITTED
       </transaction-isolation>
       <min-pool-size>25</min-pool-size>
       <max-pool-size>100</max-pool-size>
       <blocking-timeout-millis>5000</blocking-timeout-millis>
       <idle-timeout-minutes>15</idle-timeout-minutes>
       <prepared-statement-cache-size>
       75
       </prepared-statement-cache-size>
       </local-tx-datasource>
      
       <!-- add datasource for UMLS MYSQL database (Manuel Fidalgo)-->
       <local-tx-datasource>
       <jndi-name>WP7Datasource</jndi-name>
       <connection-url>jdbc:mysql://localhost/umls</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       <user-name>***</user-name>
       <password>***</password>
       <connection-property name="char.encoding">UTF-8</connection-property>
       <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
       <min-pool-size>25</min-pool-size>
       <max-pool-size>100</max-pool-size>
       <blocking-timeout-millis>5000</blocking-timeout-millis>
       <idle-timeout-minutes>15</idle-timeout-minutes>
       <prepared-statement-cache-size>75</prepared-statement-cache-size>
       <metadata> <type-mapping>mySQL</type-mapping></metadata>
       </local-tx-datasource>
      </datasources>



      and the persistence.xml is this:

      <persistence>
       <persistence-unit name="medieqDatasource">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:/medieqDatasource</jta-data-source>
       <properties>
       <!-- create-drop -->
       <property name="hibernate.hbm2ddl.auto" value="validate"/>
       <property name="hibernate.show_sql" value="true"/>
       <!-- These are the default for JBoss EJB3, but not for HEM: /-->
       <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
       <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
       <property name="jboss.entity.manager.factory.jndi.name" value="java:/medieqEntityManagerFactory"/>
       </properties>
       </persistence-unit>
      
       <!-- MySQL UMLS database Manuel Fidalgo -->
       <persistence-unit name="WP7Datasource">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:/WP7Datasource</jta-data-source>
       <properties>
       <property name="hibernate.hbm2ddl.auto" value="validate" />
       <property name="hibernate.cache.use_query_cache" value="true" />
       <property name="hibernate.show_sql" value="true" />
       <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
       <property name="hibernate.connection.username" value="***" />
       <property name="hibernate.connection.password" value="***" />
       <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
       <property name="hibernate.connection.url" value="jdbc:mysql://localhost/umls" />
       <property name="jboss.entity.manager.factory.jndi.name" value="java:/WP7EntityManagerFactory" />
       <property name="hibernate.jdbc.use_get_generated_keys" value="false" />
       </properties>
       </persistence-unit>
      </persistence>



      Both databases are working and I can connect to them via JDBC. I have no entities for the MySQL database but is should work...I think that the problem is that the configuration forces MySQL to use id generators and it doesnt work but I don't know why it uses this generators and if I could turn off this feature (only for MySQL)... Any help will be apreciated...

      thanks