Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » org.eclipse.persistence.exceptions.ValidationException(Problems during application deployment to GlassFish when with ManyToMany mappings )
org.eclipse.persistence.exceptions.ValidationException [message #791989] Mon, 06 February 2012 13:48 Go to next message
Slawomir Korbas is currently offline Slawomir KorbasFriend
Messages: 8
Registered: February 2012
Junior Member
Hello All,

I am new to Eclipse. I stuck since 3 days on strange problem. What I have done:

1. Downloaded and installed Eclipse (eclipse-jee-indigo-SR1-win32-x86_64.zip)
2. Installed GlassFish (glassfish-3.1.1-windows.exe)
3. Installed plugin for Glassfish (for Eclipse Indigio IDE)
4. Created EJB project with facets: Java,EJB,JPA 2.0
5. GlassFish target platform: "GlassFish Server Open Source(Java EE6)"
6. JPA settings - selected as Platform "EclipseLink 2.3"
7. Generated "JPA Entities form Tables"

When I am trying to deploy this application to server I receive following exception:


Exception Description: Predeployment of PersistenceUnit [MegajanServerApp] failed.
Internal Exception: Exception [EclipseLink-7333] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The reference column name [name] mapped on the element [field products] does not correspond to a valid field on the mapping reference.. Please see server.log for more details.


Here is the mapping definition generated in one of my classe:

//bi-directional many-to-many association to Product
@ManyToMany
@JoinTable(
name="job_products"
, joinColumns={
@JoinColumn(name="job_id", nullable=false)
}
, inverseJoinColumns={
@JoinColumn(name="product_name", referencedColumnName="name", nullable=false)
}
)
private List<Product> products;


In my opinion there is no problem with mapping definition but there is a bug in EclipseLink in this validation. I found no solution for this problem on the Web. What I tried:

1. Some people calimed this is case-sensitivity issue in mapping definition but this is not my case. (included in persistence.xml following line <property name="eclipselink.jpa.uppercase-column-names" value="false"/> and problem still exists)
2. Updated everything what I supposed to cause this error. Even EclipseLink 2.4.0 night build.
3. Reinstalled many times GlassFish server 3.1, Eclipse Indigio IDE
4. The strangest thing is that about 2 month ago I did the same things but on other PC machine and it worked fine. ???


I am so disappointed... How can I design reliable, distributed applications with EJB 3.1 if mentioned bugs occur? Maybe I will try NetBeans IDE.
Please, give me any solution to this problem.

Best regards,
Slawek
Re: org.eclipse.persistence.exceptions.ValidationException [message #792891 is a reply to message #791989] Tue, 07 February 2012 14:41 Go to previous messageGo to next message
Slawomir Korbas is currently offline Slawomir KorbasFriend
Messages: 8
Registered: February 2012
Junior Member
Ok. I will respond to myself Wink
Grrr!!! Finally I got it work.

What I discovered EclipseLink doesn't generate all the fields corresponding to selected tables in database when:

- there is relation defined to this field
- and the field is not a primary key - just basic column

It seems to be confirmed by:

Section 10.1.21 of the JPA spec states:

"Support for referenced columns that are not primary key columns of the
referenced table is optional. Applications that use such mappings will not be
portable."


When I added those fields manually for each generated class whole deployment to GlassFish server succeed. I don't know why all the fields of specified entity table
are not generated automatically even if I mark "Generate this property" checkbox in the wizard.
Now I can accept such a workaround but how I can deal with this bug when there will be many tables/entities???
Re: org.eclipse.persistence.exceptions.ValidationException [message #792938 is a reply to message #792891] Tue, 07 February 2012 15:32 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
looks like you are hitting bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=343632 then. Try using EclipseLink 2.3.1 or later.a
Re: org.eclipse.persistence.exceptions.ValidationException [message #792944 is a reply to message #792891] Tue, 07 February 2012 15:32 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
looks like you are hitting bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=343632 then. Try using EclipseLink 2.3.1 or later.a
Re: org.eclipse.persistence.exceptions.ValidationException [message #793532 is a reply to message #792944] Wed, 08 February 2012 08:58 Go to previous messageGo to next message
Slawomir Korbas is currently offline Slawomir KorbasFriend
Messages: 8
Registered: February 2012
Junior Member
Thank You for response.
I am using EclipseLink 2.3.1.v20110908-r10021 and there is still a problem:

The wizard for generating entities from tables doesn't generate all fields corresponding to database table. This takes place when there is relation defined and
related attribute (used to make JOINS) is not a primary key. Without defined relations (OneToMany,ManyToMany) always all fields are generated properly.

Anyway workaround with manually added fields works. However it would be difficult to make changes in many classes. In make case I had 4 relations and needed to add 4 fields
that were not generated by the wizard.

In the link You posted the same problem is described and bug has FIXED status. What was fixed? How use this fix?




Re: org.eclipse.persistence.exceptions.ValidationException [message #793832 is a reply to message #793532] Wed, 08 February 2012 16:25 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
I am not sure then what problem you are experiencing. EclipseLink DDL generation is not wizard based, so I don't know what you are using to generate fields. I am also not sure how the field existing changes the exception you get, unless you mean that the "name" field requires a basic mapping in the Product entity. If this is what you mean, please show how you have it mapped when you get the exception.

Best Regards,
Chris
Re: org.eclipse.persistence.exceptions.ValidationException [message #794619 is a reply to message #793832] Thu, 09 February 2012 14:07 Go to previous message
Slawomir Korbas is currently offline Slawomir KorbasFriend
Messages: 8
Registered: February 2012
Junior Member
From context menu (on specified package) select: "New -> "JPA Entities Form Tables" the wizard starts. This was the wizard under Eclipse Indigio with JPA 2.0 project facet turned on. I used it to generate entity classes from db tables. It has 4 stages.
One of them is used to configure table associations. There you can choose fields from tables that are related.

In my case I wanted to configure relation ManyToMany between table 'Jobs' and 'Products'. To properly generate mapping annotations on fields I pointed to third table 'Job_products' which contained entries connecting job_id's with product's names:

[Jobs] [Job_products] [Products]
id [pk]
job_id [pk] <---------> job_id prod_id [pk]
... name <-----------------------> name [not primary key!]
.... ....
.... ....


After I confirmed the wizard I noticed that for the entity 'Product' there was no field 'name' generated. This was probably because 'name' column in DB is not a primary key - just plain(indexed) attribute. When deploying on GlassFish I received mentioned exception. That is why I added following field manually to 'Product' class:

@Entity
@Table(name="products")
public class Product implements Serializable {
..........
@Column(name="name", length=255)
private String name;
............
}


Concluding I designed not the best datamodel. Maybe I should use for JOINS only primary keys not plain columns. I was not aware it is not good practice however I had reasons to do it in this way in the past. I is one of my first databases designed long time ago when implementing PHP based web service. Now I want to migrate it to JEE (EJB,JPA + JavaFX).
Anyway I tested same behavior on Netbeans. This IDE hasn't such a wizard for JPA like Eclipse. You cannot define(point) interested tables/columns for relations. The relational annotations (like MnyToMany) are generated only if database (MySQL) has InnoDB engine and attributes are marked as foreign/primary keys. So now it is hard decision which IDE I will choose. Netbeas has some things emebeded lik JavaFX 2.0 support... but it is not the subject today Wink
Previous Topic:IndirectList inserted as parent
Next Topic:Validation to DDL constraint
Goto Forum:
  


Current Time: Thu Apr 25 21:41:19 GMT 2024

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

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

Back to the top