Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsChange database schema at runtime
https://www.eclipse.org/forums/index.php/mv/msg/207462/664304/#msg_664304
in my application which uses EclipseLink 1.1.1 I'd like to change database at runtime.
The reason is this: on MySQL server there are several databases with identical structure. Decission which database use is made in application at runtime and it may change during the application lifecycle.
Is the only solution to have one persistent unit for each database?
Thanks for help.]]>Pavel Zelenka2011-04-08T10:28:59-00:00Re: Change database schema at runtime
https://www.eclipse.org/forums/index.php/mv/msg/207462/664690/#msg_664690
Or you could have a single persistence unit, but create a different EntityManagerFactory for each database. You would pass a properties into the createEntityManagerFactory, and give the new url for the database.
]]>James Sutherland2011-04-11T15:37:09-00:00Re: Change database schema at runtime
https://www.eclipse.org/forums/index.php/mv/msg/207462/664876/#msg_664876
Pavel Zelenka2011-04-12T11:17:30-00:00Re: Change database schema at runtime
https://www.eclipse.org/forums/index.php/mv/msg/207462/665064/#msg_665064
Pavel Zelenka2011-04-13T07:35:42-00:00Re: Change database schema at runtime
https://www.eclipse.org/forums/index.php/mv/msg/207462/665415/#msg_665415
What properties are you setting?
]]>James Sutherland2011-04-14T14:54:35-00:00Re: Change database schema at runtime
https://www.eclipse.org/forums/index.php/mv/msg/207462/665456/#msg_665456
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistencehttp://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="myPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider >
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="eclipselink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="eclipselink.jdbc.user" value="..."/>
<property name="eclipselink.jdbc.password" value="..."/>
<property name="eclipselink.logging.level" value="INFO"/>
</properties>
<class>...</class>
</persistence-unit>
</persistence>