[jboss-user] [JBoss Seam] - Re: Dynamic data sources with EntityManager

wiberto do-not-reply at jboss.com
Mon Aug 6 18:37:23 EDT 2007


I think I got this figured out now!!!

I was able to create my own persistence context as I stated in the previous post, and I'm then creating my own entitymanager factory. there I point to the the persistence unit I want to use.

Now the issue I have is that I want to pass overrides to the entitymanager factory. My persistence.xml looks like this:


  | <persistence-unit name="userbased" transaction-type="RESOURCE_LOCAL">
  | 		<provider>org.hibernate.ejb.HibernatePersistence</provider>	
  | 		<class>com.numbersinsight.data.customer.User</class>	
  | 		<properties>
  | 			<property name="hibernate.dialect"
  | 				value="org.hibernate.dialect.MySQLDialect" />
  | 			<property name="hibernate.connection.driver_class"
  | 				value="com.mysql.jdbc.Driver" />
  | 			<property name="hibernate.connection.username" value="numins" />
  | 			<property name="hibernate.connection.password" value="num6482bersi" />
  | 			<property name="hibernate.connection.url"
  | 				value="jdbc:mysql://localhost:3306/numins" />
  | 			<property name="hibernate.hbm2ddl.auto" value="none" />
  | 			<property name="hibernate.show_sql" value="true" />
  | 			<property name="hibernate.use_sql_comments" value="true" />
  | 		</properties>
  | 		<non-jta-data-source>java:jdbc/numins</non-jta-data-source>
  | 	</persistence-unit>
  | 

The connection is always made using the data source deifnintion. If I take that out the application will not deploy complaining about not having a data source defined. Do you know of a way to not have that data source defined and have it use the properties?

This way it will make it easy to load the properties and configure the connection properties at runtime based on the user.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4071394#4071394

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4071394



More information about the jboss-user mailing list