Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] BasicCollection question

Are you specifying any other field level annotations? You can not combine Field level and property level annotations in JPA 1.0
--Gordon

Martijn Morriën wrote:
The EclipseLink wiki page:
http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_(ELUG)#How_to_Use_the_.40BasicCollection_Annotation
gives an example on how to use BasicCollection. However I could not
get it to work when I use the example:

@Entity
public class Employee implements Serializable{
    ...
    @BasicCollection (
        fetch=FetchType.EAGER,
        valueColumn=@Column(name="DESCRIPTION")
    )
    @CollectionTable (
        name="RESPONS",
        primaryKeyJoinColumns=
        {@PrimaryKeyJoinColumn(name="EMPLOYEE_ID",
referencedColumnName="EMP_ID")}
    )
    public Collection getResponsibilities() {
        return responsibilities;
    }
    ...
}

I get an exception:

Exception Description: The type [interface java.util.Collection] for
the attribute [responsibilities] on the entity class [class
testjpa.User] is not a valid type for a serialized mapping. The
attribute type must implement the Serializable interface.


It works when I add the annotation on the 'responsibilities' class
member as follows:

    @BasicCollection (
        fetch=FetchType.EAGER,
        valueColumn=@Column(name="ROLE")
    )
    @CollectionTable (
        name="USER_ROLE",
        primaryKeyJoinColumns={
    		@PrimaryKeyJoinColumn(
    				name="USERID",
    				referencedColumnName="ID")
        }
    )
    Collection responsibilities;

    public Collection getResponsibilities() {
		return responsibilities;
    }

What did I do wrong? Or is the documentation using a construct I'm not
aware of...?

I also looked at the source code at
svn://dev.eclipse.org/svnroot/rt/org.eclipse.persistence and I could
not find 1 BasicCollection test or demo, are there any tests using
BasicCollection?

Thank you,

Martijn
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top