Mystery solved! The @Column annotations for the primary key fields don't go on the entity bean at all. They go on the methods in the @IdClass only, though it doesn't break if they are in both places.
I now know that Bill refrained from the @Column annotations for clarity of the example, but beware of this in the book. Code below. Hope this helps someone. Entity package com.company.project.entity; | | import java.util.Date; | | import javax.persistence.Column; | import javax.persistence.Entity; | import javax.persistence.Id; | import javax.persistence.IdClass; | import javax.persistence.Table; | | import org.jboss.seam.annotations.Name; | @Entity | @Name("streetWatchEntity") | @Table(name = "DWL_STREET_WATCH_LIST") | @IdClass(StreetWatchPK.class) | public class StreetWatchEntity implements java.io.Serializable { | private static final long serialVersionUID = 4855048029589330487L; | | /** | * PRIMARY KEY FIELD | * Retrieves the UserKey from the entity | */ | @Id | public Long getUserKey() { | return this.userKey; | } | | /** | * Sets the UserKey of the entity | */ | public void setUserKey(Long userKey) { | this.userKey = userKey; | } | | /** | * PRIMARY KEY FIELD | * Retrieves the LocationId from the entity | */ | @Id | public Long getLocationId() { | return this.locationId; | } | | /** | * Sets the LocationId of the entity | */ | public void setLocationId(Long locationId) { | this.locationId = locationId; | } | | /** | * PRIMARY KEY FIELD | * Retrieves the AreaId from the entity | */ | @Id | public Integer getAreaId() { | return this.areaId; | } | | /** | * Sets the AreaId of the entity | */ | public void setAreaId(Integer areaId) { | this.areaId = areaId; | } | | /** | * PRIMARY KEY FIELD | * Retrieves the AddressStandardized from the entity | */ | @Id | public String getAddressStandardized() { | return this.addressStandardized; | } | | /** | * Sets the AddressStandardized of the entity | */ | public void setAddressStandardized(String addressStandardized) { | this.addressStandardized = addressStandardized; | } | | /** | * Retrieves the Address from the entity | */ | @Column(name = "ADDRESS", length = 128, nullable = true) | public String getAddress() { | return this.address; | } | | /** | * Sets the Address of the entity | */ | public void setAddress(String address) { | this.address = address; | } | | /** | * Retrieves the LastUpdate from the entity | */ | @Column(name = "LAST_UPDATE", length = 7, nullable = true) | public Date getLastUpdateDate() { | return this.lastUpdateDate; | } | | /** | * Sets the LastUpdate of the entity | */ | public void setLastUpdateDate(Date lastUpdate) { | this.lastUpdateDate = lastUpdate; | } | | /** | * Retrieves the SeqNumber from the entity | */ | @Column(name = "SEQ_NUMBER", length = 22, nullable = false) | public Long getSeqNumber() { | return this.seqNumber; | } | | /** | * Sets the SeqNumber of the entity | */ | public void setSeqNumber(Long seqNumber) { | this.seqNumber = seqNumber; | } | private String address = null; | private String addressStandardized = null; | private Integer areaId = null; | private Date lastUpdateDate = null; | private Long locationId = null; | private Long seqNumber = null; | private Long userKey = null; | } IdClass package com.company.project.entity; | | import java.io.Serializable; | | import javax.persistence.Column; | | public class StreetWatchPK implements Serializable{ | private static final long serialVersionUID = 3355389391459690610L; | | private String addressStandardized = null; | | private Integer areaId = null; | | private Long locationId = null; | | private Long userKey = null; | | /** | * No-arg constructor | */ | public StreetWatchPK() {} | | public StreetWatchPK(Long userKey, Long locationId, String addressStandardized, Integer areaId) { | this.userKey = userKey; | this.locationId = locationId; | this.addressStandardized = addressStandardized; | this.areaId = areaId; | } | | @Override | public boolean equals(Object obj) { | if (obj == this) | return true; | if (!(obj instanceof StreetWatchPK)) | return false; | StreetWatchPK pk = (StreetWatchPK) obj; | | //User Key | if(locationId.longValue() != pk.getLocationId().longValue()){ | return false; | } | //Location Id | if(userKey.longValue() != pk.getUserKey().longValue()){ | return false; | } | //Area Id | if(areaId.intValue() != pk.getAreaId().intValue()){ | return false; | } | if (!addressStandardized.equals(pk.getAddressStandardized())){ | return false; | } | return true; | } | | @Override | public int hashCode() { | return addressStandardized.hashCode() + | (int)areaId.intValue() + | (int)locationId.longValue() + | (int)userKey.longValue(); | } | | /** | * @return the addressStandardized | */ | @Column(name = "ADDRESS_STANDARDIZED", length = 128, nullable = false) | public String getAddressStandardized() { | return addressStandardized; | } | | /** | * @param addressStandardized the addressStandardized to set | */ | public void setAddressStandardized(String addressStandardized) { | this.addressStandardized = addressStandardized; | } | | /** | * @return the areaId | */ | @Column(name = "AREA_ID", length = 22, nullable = false) | public Integer getAreaId() { | return areaId; | } | | /** | * @param areaId the areaId to set | */ | public void setAreaId(Integer areaId) { | this.areaId = areaId; | } | | /** | * @return the locationId | */ | @Column(name = "LOCATION_ID", length = 22, nullable = false) | public Long getLocationId() { | return locationId; | } | | /** | * @param locationId the locationId to set | */ | public void setLocationId(Long locationId) { | this.locationId = locationId; | } | | /** | * @return the userKey | */ | @Column(name = "USER_KEY", length = 22, nullable = false) | public Long getUserKey() { | return userKey; | } | | /** | * @param userKey the userKey to set | */ | public void setUserKey(Long userKey) { | this.userKey = userKey; | } | | } | View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3984303#3984303 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3984303 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user