• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

JPA Provider issue

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I'm using Toplink as provider for JPA and here is my persistance.xml



but when exception is logged it says EclipseLink exception


Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException



I'm using maven and put persistance.xml under src/main/resources/META-INF

why it says eclipselink ?!


thanks,
Amr Khaled
 
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amr

Can you post the full stack trace of the exception please?
 
Amr k. Saleh
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just know it was working before i move to maven, and what i noticed is it says eclipselink

 
Bartender
Posts: 543
4
Netbeans IDE Redhat Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EclipseLink basically IS TopLink open sourced. I think your issue is more data-related. Check if the merchant_id FK in the record you're trying to insert has a corresponding id in the Merchant table.
 
Amr k. Saleh
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
aha, i see

what i'm doing is inserting new merchant and new store at the same time, it was working before i don't know what happened !!
 
Dieter Quickfend
Bartender
Posts: 543
4
Netbeans IDE Redhat Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When mavenizing, did you make sure to specify all the same versions you were using before you mavenized?
 
James Boswell
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't see how this is an issue with Maven.

As stated previously, it is to do with the data being inserted into the database violating a foreign key constraint.
 
Dieter Quickfend
Bartender
Posts: 543
4
Netbeans IDE Redhat Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James, it's definitely not a Maven issue... But it might be related to different versions of TopLink... I seem to remember there used to be a bug with TopLink not allowing automatic FK generation, and he's pretty adamant that nothing has changed apparently...

Even so, Amr, first thing I would try is check if you have cascade=PERSIST or ALL set on your relationship. If not, set it. In this case, it cannot have worked before. If it is there, persist the Merchant, flush the EntityManager, and then persist the Store. That ought to work. Your merchant will be in the database, and your FK constraint will not fail. If this fixes it, it might be due to TopLink. If it still doesn't work, you'll definitely have a different error message.

And please, next time post all the relevant code and configs, not just the error message.
 
Amr k. Saleh
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, i have a Merchant entity that extend User entity

User entity



Merchant entity



and Merchant entity has a list of store entity





and that is the code that inserts Merchant entity




i logged the generated queries and i found out that it inserts User then Store and that is why it voilate the FK constraint because there is no merchant yet, how can i solve this ?

 
Amr k. Saleh
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here the maven dependencies

 
James Boswell
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The actual code that persists the merchant entity is

userService.registerMerchant

Can you post this code please?
 
Amr k. Saleh
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked when i changed the provider to Hibernate !
 
    Bookmark Topic Watch Topic
  • New Topic