Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Re: JPA/EclipseLink 1.0.2 J2SE Project: emf.createEntityManager() truncates tables
Re: JPA/EclipseLink 1.0.2 J2SE Project: emf.createEntityManager() truncates tables [message #385745] Sun, 01 March 2009 16:30 Go to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Andi,

You'd be better to ask the author directly, I see there's a link for
that, or to use the EclipseLink newsgroup, which I've added to the "to"
list of the reply.


Andi wrote:
> I followed some tutorials as e.g.
> http://www.vogella.de/articles/JavaPersistenceAPI/article.ht ml to
> setup a Java/JPA project.
>
> I am using a MySQL 5 database together with the MySQLConnector v5.0.4
> and EclipseLink 1.0.2.
>
> I defined a set of entities. Automatic creation of DDL in the database
> works. I successfully create some entries in the tables
> programatically, starting with a JUnit4 Test.
>
> The problem is, that everytime I create a new entity manager all
> mapped tables are truncated. Thus, every query on a new entity manager
> returns an empty result.
>
> The test case:
> @Before
> public void setUp() throws Exception {
> emf = Persistence.createEntityManagerFactory("TestJPA");
> }
>
> @Test
> public void doNothing() {
> emf.createEntityManager().close();
> }
>
> @After
> public void tearDown() {
> emf.close();
> }
>
> results in an empty database.
>
> I am afraid, I have some kind of fundamental misunderstanding. The
> vogella tutorial and all others that I have found do a setup (@Before)
> that create all queried data in advance, but do not explain why. How
> can I read peristed data?
>
> This is my persistence.xml:
> <?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/persistence
> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
> <persistence-unit name="TestJPA" transaction-type="RESOURCE_LOCAL">
> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider >
> <class>model.Family</class>
> <class>model.Job</class>
> <class>model.Person</class>
> <class>model.OfficeJob</class>
> <class>model.OutdoorJob</class>
> <class>model.Animal</class>
> <properties>
> <property name="eclipselink.jdbc.url"
> value="jdbc:mysql://localhost:3306/test01"/>
> <property name="eclipselink.jdbc.user" value="root"/>
> <property name="eclipselink.jdbc.password" value=""/>
> <property name="eclipselink.jdbc.driver"
> value="com.mysql.jdbc.Driver"/>
> <property name="eclipselink.ddl-generation"
> value="drop-and-create-tables" />
> <property name="eclipselink.ddl-generation.output-mode"
> value="database" />
> <property name="eclipselink.target-database" value="MySQL4"/>
> </properties>
> </persistence-unit>
> </persistence>
>
>
> Thank you for your help in advance,
>
> Andi
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: JPA/EclipseLink 1.0.2 J2SE Project: emf.createEntityManager() truncates tables [message #385746 is a reply to message #385745] Sun, 01 March 2009 17:53 Go to previous messageGo to next message
Andi is currently offline AndiFriend
Messages: 5
Registered: July 2009
Junior Member
Thank you for your answer, I have also posted on the vogella group.

Andi
Re: JPA/EclipseLink 1.0.2 J2SE Project: emf.createEntityManager() trunc SOLVED [message #385749 is a reply to message #385746] Tue, 03 March 2009 13:25 Go to previous messageGo to next message
Andi is currently offline AndiFriend
Messages: 5
Registered: July 2009
Junior Member
This problem was solved. See
http://groups.google.com/group/vogella/browse_thread/thread/ 73600469ca46e104#
Re: JPA/EclipseLink 1.0.2 J2SE Project: emf.createEntityManager() trunc SOLVED [message #385750 is a reply to message #385749] Wed, 04 March 2009 12:01 Go to previous message
Doug Clarke is currently offline Doug ClarkeFriend
Messages: 155
Registered: July 2009
Senior Member
Here is a documentation link explaining the different schema generation
modes. All of EclipseLink JPA's properties are applied at runtime.

http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_ (ELUG)#Using_EclipseLink_JPA_Extensions_for_Schema_Generatio n

Doug
Previous Topic:PersistenceUnitInfo xxx has transactionType JTA, but doesnt have jtaDataSource
Next Topic:JPQL - Join + Select in
Goto Forum:
  


Current Time: Tue Apr 23 15:30:01 GMT 2024

Powered by FUDForum. Page generated in 0.02807 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top