Hi Mansour,
I agree that the message is messed up a bit...  This particular message is
used in a few different locations in the code.  If you have additional
context about when this is received (call stack, persistent operation,
etc), it would help with identifying the specific usage and get that
cleaned up.

Looking at your example, a couple of things jump out...

1)  In your PK class, your getter/setter methods don't match the strId
attribute (get/setMessage?).  These names need to follow standard java bean
conventions and need to match up.

2)  In your GeoAssociation class...  It looks like you want the ability to
setGeo and setStrId, but I don't see those methods defined.  You have them
defined (sort of, per my first comment) in your PK class.  But, you don't
have them defined in your GeoAssoc class.

That's all I've got at this point.
Kevin


On Wed, Jan 29, 2014 at 11:48 PM, Mansour Al Akeel <
mansour.alak...@gmail.com> wrote:

> Hello all,
>
> I need to create a primary key in my tables, and set constrains on
> them. So I have few tables:
>
> 1- Geo
> 2- GeoAssociation
>
> For the GeoAssociation, I need a primary key GeoAssociationPK. The PK
> has a field, that "HAS" to be a geo_id. So here's the definition I
> have for GeoAssociation:
>
>
>
> @Embeddable
> public class GeoAssociationPK implements Serializable {
>
>     private String strId;
>
>     private Geo geo;
>
>     @Column(name = "str_id")
>     public String getMessage() {
>         return strId;
>     }
>
>     public void setMessage(String message) {
>         this.strId = message;
>     }
>
>     @ManyToOne(optional = false)
>     @Column(name = "geo_id")
>     public Geo getGeo() {
>         return geo;
>     }
>
>     public void setGeo(Geo geoFrom) {
>         this.geo = geoFrom;
>     }
>
>     @Override
>     public boolean equals(Object obj) {
>         throw new UnsupportedOperationException("Not implemented");
>     }
>
>     @Override
>     public int hashCode() {
>         throw new UnsupportedOperationException("Not implemented");
>     }
>
> }
>
>
>
> This is how I define the GeoAssociation class:
>
> @Entity
> @Access(AccessType.PROPERTY)
>
> public class GeoAssoc {
>
>     @EmbeddedId
>     private GeoAssociationPK id = new GeoAssociationPK();
>
>     private GeoAssocType type;
>
>     @ManyToOne(fetch = FetchType.LAZY)
>     @JoinColumn(name = "type")
>     public GeoAssocType getType() {
>         return type;
>     }
>
>     public void setType(GeoAssocType value) {
>         this.type = value;
>     }
>
>     public Geo getGeoFrom() {
>         return this.id.getGeo();
>     }
>
>     @Override
>     public boolean equals(Object obj) {
>         throw new UnsupportedOperationException("Not implemented");
>     }
>
>     @Override
>     public int hashCode() {
>         throw new UnsupportedOperationException("Not implemented");
>     }
>
> }
>
>
> The error I am getting when building with maven enhancer is:
>
> The id class specified by type "class entities.geo.GeoAssoc" does not
> match the primary key fields of the class.  Make sure your identity
> class has the same primary keys as your persistent type, including pk
> field types. Mismatched property: "geo" -> [Help 1]
>
> I don't understand the error message or how to solve it. What I need
> is to be able to create and persist entity without having to
> explicitly create the PK.
>
> For example :
> GeoAssociation gs = new GeoAssociation();
> gs.setGeo(myGeo);
> gs.setStrId(someString);
>
>
> My question is how to achieve this, and resolve this error message ?
>
>
> Thank you in advance.
>

Reply via email to