[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [eclipselink-users] @Id ValidationException with EclipseLink - see new bug# 240679 - 2nd workaround verification
|
David,
For workaround 2 - use an orm.xml annotation, I verified the following change if you don't want to move your annotations to your fields and keep your entities as-is.
Entity superclass
-----------------
@MappedSuperclass abstract public class StatAbstractClass implements Serializable {
private BigDecimal id;
orm.xml
--------
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings version="1.0" xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd">
<description>Workaround for http://bugs.eclipse.org/240679 </description>
<package>org.eclipse.persistence.example.navigation.business</package>
<entity name="StatClass" class="StatClass" access="PROPERTY">
</entity>
</entity-mappings>
output
------
[EL Finest]: 2008.07.14 10:45:25.452--UnitOfWork(10625551)--Thread(Thread[main,5,main])--Execute query InsertObjectQuery(org.eclipse.persistence.example.navigation.business.StatClass@167c6fd)
[EL Fine]: 2008.07.14 10:45:25.452--ClientSession(26285376)--Connection(8304354)--Thread(Thread[main,5,main])--INSERT INTO STAT_CLASS (ID, JDK_VERSION, MODIFIED, INTERNAL, LINES, TEST, CLASS_TYPE_CODE, NAME, VERSION, LABEL, CLASS_TYPE, CLASS_PACKAGE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
bind => [28160, null, 2008-07-03, null, 28, 0, null, DescriptorCompare, concrete, 1201, null, 2839]
thank you
/michael
-----Original Message-----
From: MICHAEL.OBRIEN@xxxxxxxxxx
Sent: Monday, July 14, 2008 10:18
To: EclipseLink User Discussions
Subject: RE: [eclipselink-users] @Id ValidationException with
EclipseLink - see new bug# 240679
David,
After further investigation surrounding @MappedSuperclass (which I have just started to use today) with Guy, Gordon and Tom - your issue is a bug.
We have raised bug# 240679 where you may track progress.
http://bugs.eclipse.org/240679
The workarounds can be either
1) move (ALL) your annotations to your fields on your superclass - verified
2) or define the attribute type on the descriptor to METHOD
see : http://java.sun.com/javaee/5/docs/api/javax/persistence/AttributeOverride.html
thank you for raising this issue.
/michael
-----Original Message-----
From: MICHAEL.OBRIEN@xxxxxxxxxx
Sent: Monday, July 14, 2008 09:12
To: EclipseLink User Discussions
Subject: RE: [eclipselink-users] @Id ValidationException with
EclipseLink
David,
Hi, try moving your @Id, @SequenceGenerator and @GeneratedValue annotations up from the getId() function to your instance variable...
private Integer id;
I recall having to put annotations on either the instance variable only, or both the instance variable and the getter function - but the instance variable annotation should take precedence.
I have an example like yours and tested this scenario and got the same exception by moving the annotations down to the getId()
WORKING-------------------------------------------------------------------------------
@Id
@SequenceGenerator(name="STAT_SEQUENCE_CLASS", sequenceName="STAT_CLASS_SEQ_GENERATOR", allocationSize=25)
@GeneratedValue(generator="STAT_SEQUENCE_CLASS")
private BigDecimal id;
public BigDecimal getId() {
return this.id;
}
[EL Config]: 2008.07.14 09:11:26.112--ServerSession(25300442)--Thread(Thread[main,5,main])--The alias name for the entity class [class org.eclipse.persistence.example.navigation.business.StatClass] is being defaulted to: StatClass.
[EL Config]: 2008.07.14 09:11:26.127--ServerSession(25300442)--Thread(Thread[main,5,main])--The column name for element [private java.math.BigDecimal org.eclipse.persistence.example.navigation.business.StatClass.id] is being defaulted to: ID.
EL Fine]: 2008.07.14 09:09:19.833--ClientSession(11644607)--Connection(7812797)--Thread(Thread[main,5,main])--INSERT INTO STAT_CLASS (ID, JDK_VERSION, CLASS_TYPE_CODE, MODIFIED, INTERNAL, NAME, LINES, VERSION, TEST, CLASS_PACKAGE, LABEL, CLASS_TYPE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
bind => [14591, null, null, 2008-07-03, null, EqualsNode, 79, concrete, 0, 1069, 1001, null]
BROKEN--------------------------------------------------------------------------------
private BigDecimal id;
@Id
@SequenceGenerator(name="STAT_SEQUENCE_CLASS", sequenceName="STAT_CLASS_SEQ_GENERATOR", allocationSize=25)
@GeneratedValue(generator="STAT_SEQUENCE_CLASS")
public BigDecimal getId() {
return this.id;
}
Caused by: Exception [EclipseLink-7161] (Eclipse Persistence Services - 1.0 (Build SNAPSHOT - 20080708)): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class org.eclipse.persistence.example.navigation.business.StatClass] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then please make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
at org.eclipse.persistence.exceptions.ValidationException.noPrimaryKeyAnnotationsFound(ValidationException.java:1234)
thank you
/michael
-----Original Message-----
From: David Nedrow [mailto:dnedrow@xxxxxxx]
Sent: Sunday, July 13, 2008 23:09
To: List - EclipseLink Users
Subject: [eclipselink-users] @Id ValidationException with EclipseLink
I've got about 10 classes that I have implemented via EclipseLink
(1.0) annotations that all appear to work fine.
I added a new entity, but now I get the following annotation error
when trying to deploy the app in GlassFish (V2.1)...
Deploying application in domain failed; Exception [EclipseLink-28018]
(Eclipse Persistence Services - 1.0 (Build 1.0 - 20080707)):
org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [NetConfPU]
failed.
Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence
Services - 1.0 (Build 1.0 - 20080707)):
org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class
com.foo.ncs.argfrp.jpa.netconf.AclAddrDst] has no primary key
specified. It should define either an @Id, @EmbeddedId or an @IdClass.
If you have defined PK using any of these annotations then please make
sure that you do not have mixed access-type (both fields and
properties annotated) in your entity class hierarchy.
So far as I can tell, I've done everything the same for the entities
I've constructed that work fine.
Can anyone see a problem with what I have below?
/* AbstractAclAddrDst.java */
package com.foo.ncs.argfrp.jpa.netconf;
//~--- JDK imports
------------------------------------------------------------
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.SequenceGenerator;
/**
* AbstractAclAddrDst entity provides the base persistence definition
of the
* AclAddrDst entity.
*
*/
@MappedSuperclass public abstract class AbstractAclAddrDst implements
java.io.Serializable {
// Fields
private Integer id;
private FilterAccess filterAccess;
private Integer address;
// Constructors
/** default constructor */
public AbstractAclAddrDst() {}
/** full constructor */
public AbstractAclAddrDst(Integer id, FilterAccess filterAccess,
Integer address) {
this.id = id;
this.filterAccess = filterAccess;
this.address = address;
}
// Property accessors
/**
* Method description
*
*
* @return
*/
@SequenceGenerator(name = "ACLADDRDST_SEQ", sequenceName =
"acl_addr_dst_id_seq")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
"ACLADDRDST_SEQ")
@Id @Column(
name = "id",
unique = true,
nullable = false
)
public Integer getId() {
return this.id;
}
/**
* Method description
*
*
* @param id
*/
public void setId(Integer id) {
this.id = id;
}
/**
* Method description
*
*
* @return
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "filter_accessid", nullable = false)
public FilterAccess getFilterAccess() {
return this.filterAccess;
}
/**
* Method description
*
*
* @param filterAccess
*/
public void setFilterAccess(FilterAccess filterAccess) {
this.filterAccess = filterAccess;
}
/**
* Method description
*
*
* @return
*/
@Column(name = "address", nullable = false)
public Integer getAddress() {
return this.address;
}
/**
* Method description
*
*
* @param address
*/
public void setAddress(Integer address) {
this.address = address;
}
}
//~ Formatted in Sun Code Convention on 2008-07-13
and the concrete class...
/* AclAddrDst.java */
package com.foo.ncs.argfrp.jpa.netconf;
//~--- JDK imports
------------------------------------------------------------
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* AclAddrDst entity.
*
*/
@Entity @Table(name = "acl_addr_dst")
public class AclAddrDst extends AbstractAclAddrDst implements
java.io.Serializable {
// Constructors
/** default constructor */
public AclAddrDst() {}
/** full constructor */
public AclAddrDst(Integer id, FilterAccess filterAccess, Integer
address) {
super(id, filterAccess, address);
}
}
//~ Formatted in Sun Code Convention on 2008-07-13
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users