Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » @OneToMany does not work with schema-generation = drop-and-create
icon4.gif  @OneToMany does not work with schema-generation = drop-and-create [message #1699092] Sat, 20 June 2015 19:10 Go to next message
Reda J. is currently offline Reda J.Friend
Messages: 2
Registered: June 2015
Junior Member
Hello,
after much research , I finally found the cause of failure.
@OneToMany does not work (return null) when persistence.xml contains:

(drop-and-create)
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>


But it works well with this:
(none)
<property name="javax.persistence.schema-generation.database.action" value="none"/>


Here are all the code of the file persistence.xml:
[__xmlns_URL__ : replaces the URL of xmlns , because the forum does not Authorise external urls ]
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" __xmlns_URL__ >
  <persistence-unit name="XXXX-ejbPU" transaction-type="JTA">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <jta-data-source>jdbc/xxxxDatasource</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <shared-cache-mode>ALL</shared-cache-mode>
    <!-- ALL  ! voir l'option selective ! elle est trés intérésséente -->
    <properties>
      <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
      <property name="eclipselink.target-database" value="MySQL"/>
      <property name="eclipselink.logging.level.sql" value="OFF"/>
      <property name="eclipselink.logging.parameters" value="true"/>
      <property name="eclipselink.persistence-context.flush-mode" value="AUTO"/>
    </properties>
  </persistence-unit>
</persistence>


P.S: @OneToMany works correctly with Hibernate.

Thanks.

Re: @OneToMany does not work with schema-generation = drop-and-create [message #1699494 is a reply to message #1699092] Wed, 24 June 2015 15:07 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
I don't understand what isn't working or how schema generation would break something. The Drop and create tables would remove any data you have in the database, so could your app be reading something that got removed and expect it to be there?
Re: @OneToMany does not work with schema-generation = drop-and-create [message #1699693 is a reply to message #1699494] Thu, 25 June 2015 21:33 Go to previous messageGo to next message
Reda J. is currently offline Reda J.Friend
Messages: 2
Registered: June 2015
Junior Member
Hello,
Thank you for your interest Chris Delahunt,
the application automatically generates its data during a first deployement,

Bug details are here:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=470659

Thanks.
Re: @OneToMany does not work with schema-generation = drop-and-create [message #1700210 is a reply to message #1699693] Tue, 30 June 2015 19:01 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
The bug does not have enough information to reproduce a problem, or show what your issue really is. Since you outline workarounds of disabling DDL generation, or clearing the cache, I suspect your problem has to do with how you are creating entities and putting them into the cache when they do not already exist. The relationship will be null if you haven't set it.

You can verify what might be happening by calling em.refresh() on the entity with the null OneToMany relationship and see what is returned. If the relationship is then populated, the issue is likely with your application and how this object is being persisted.

Best Regards,
Chris
Previous Topic: Reusing a column across subclasses in eclipselink single table inheritance
Next Topic:Query Caching
Goto Forum:
  


Current Time: Fri Apr 26 11:32:13 GMT 2024

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

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

Back to the top