[jboss-user] [EJB 3.0] - AnnotationException: xxx not mapped to a single property...

ttrepper do-not-reply at jboss.com
Fri Aug 31 05:51:12 EDT 2007


Hi all, 

i get the following AnnotationException, and i don´t know why?




SQL:

  | CREATE TABLE Party (
  |     PartyID BIGINT DEFAULT nextval('seq_PartyID')  NOT NULL,
  |     DateAdded TIMESTAMP DEFAULT current_timestamp,
  |     ActiveUntil TIMESTAMP,
  |     CONSTRAINT PK_Party PRIMARY KEY (PartyID)
  | );
  | 
  | CREATE TABLE PartyIsPerson (
  |     PartyIDPerson BIGINT  NOT NULL,
  |     Title CHARACTER VARYING(40),
  |     Forename CHARACTER VARYING(80)  NOT NULL,
  |     Lastname CHARACTER VARYING(80)  NOT NULL,
  |     Birthday DATE,
  |     Gender CHARACTER(1),
  |     MaritalStatus CHARACTER(1),
  |     CONSTRAINT PK_PartyIsPerson PRIMARY KEY (PartyIDPerson)
  | );
  | 
  | CREATE TABLE PersonHasStoredSearches (
  |     PartyIDPerson BIGINT  NOT NULL,
  |     SequenceNumber SMALLINT  NOT NULL,
  |     SearchName CHARACTER VARYING(100),
  |     SearchPattern CHARACTER VARYING(100)  NOT NULL,
  |     Active BOOLEAN DEFAULT true,
  |     DateAdded TIMESTAMP DEFAULT current_timestamp,
  |     ActiveUntil TIMESTAMP,
  |     CONSTRAINT PK_PersonHasStoredSearches PRIMARY KEY (PartyIDPerson, SequenceNumber)
  | );
  | 
  | CREATE TABLE PersonHasStoredReminders (
  |     PartyIDPerson BIGINT  NOT NULL,
  |     SequenceNumber SMALLINT  NOT NULL,
  |     ReminderName CHARACTER VARYING(100),
  |     Schedule TIMESTAMP,
  |     Active BOOLEAN,
  |     DateAdded TIMESTAMP DEFAULT current_timestamp,
  |     ActiveUntil TIMESTAMP,
  |     CONSTRAINT PK_PersonHasStoredReminders PRIMARY KEY (PartyIDPerson, SequenceNumber)
  | );
  | 
  | CREATE TABLE SearchUsesReminder (
  |     PartyIDPersonReminder BIGINT  NOT NULL,
  |     SequenceNumberReminder SMALLINT  NOT NULL,
  |     PartyIDPersonSearch BIGINT  NOT NULL,
  |     SequenceNumberSearch SMALLINT  NOT NULL,
  |     DateAdded TIMESTAMP DEFAULT current_timestamp,
  |     ActiveUntil TIMESTAMP,
  |     CONSTRAINT PK_SearchUsesReminder PRIMARY KEY (PartyIDPersonReminder, SequenceNumberReminder, PartyIDPersonSearch, SequenceNumberSearch)
  | );
  | 

The important table is the last one, which uses the two before.
The tables PersonHasStoredReminders and PersonHasStoredSearches  have the PartyIDPerson as a primary key PLUS an incremented (mini)-sequence. Therefore the last table (SearchUsesReminder) has to use both PKs, (4 columns) also as PK.

Class Personhasstoredreminders

  | package com.auctonova.ejb.persistence;
  | 
  | import java.io.Serializable;
  | import java.sql.Timestamp;
  | import java.util.Set;
  | import javax.persistence.Embeddable;
  | import javax.persistence.EmbeddedId;
  | import javax.persistence.Entity;
  | import javax.persistence.JoinColumn;
  | import javax.persistence.ManyToOne;
  | import javax.persistence.OneToMany;
  | 
  | @Entity
  | public class Personhasstoredreminders implements Serializable {
  | 	@EmbeddedId
  | 	private Personhasstoredreminders.PK pk;
  | 
  | 	private Timestamp activeuntil;
  | 
  | 	private short active;
  | 
  | 	private Timestamp schedule;
  | 
  | 	private String remindername;
  | 
  | 	private Timestamp dateadded;
  | 
  | 	@ManyToOne
  | 	@JoinColumn(name="partyidperson")
  | 	private Partyisperson partyidperson;
  | 
  | 	@OneToMany(mappedBy="personhasstoredreminders")
  | 	private Set<Searchusesreminder> searchusesreminderCollection;
  | 
  | 	private static final long serialVersionUID = 1L;
  | 
  | 	public Personhasstoredreminders() {
  | 		super();
  | 	}
  | 
  | 	public Personhasstoredreminders.PK getPk() {
  | 		return this.pk;
  | 	}
  | 
  | 	public void setPk(Personhasstoredreminders.PK pk) {
  | 		this.pk = pk;
  | 	}
  | 
  | 	public Timestamp getActiveuntil() {
  | 		return this.activeuntil;
  | 	}
  | 
  | 	public void setActiveuntil(Timestamp activeuntil) {
  | 		this.activeuntil = activeuntil;
  | 	}
  | 
  | 	public short getActive() {
  | 		return this.active;
  | 	}
  | 
  | 	public void setActive(short active) {
  | 		this.active = active;
  | 	}
  | 
  | 	public Timestamp getSchedule() {
  | 		return this.schedule;
  | 	}
  | 
  | 	public void setSchedule(Timestamp schedule) {
  | 		this.schedule = schedule;
  | 	}
  | 
  | 	public String getRemindername() {
  | 		return this.remindername;
  | 	}
  | 
  | 	public void setRemindername(String remindername) {
  | 		this.remindername = remindername;
  | 	}
  | 
  | 	public Timestamp getDateadded() {
  | 		return this.dateadded;
  | 	}
  | 
  | 	public void setDateadded(Timestamp dateadded) {
  | 		this.dateadded = dateadded;
  | 	}
  | 
  | 	public Partyisperson getPartyidperson() {
  | 		return this.partyidperson;
  | 	}
  | 
  | 	public void setPartyidperson(Partyisperson partyidperson) {
  | 		this.partyidperson = partyidperson;
  | 	}
  | 
  | 	public Set<Searchusesreminder> getSearchusesreminderCollection() {
  | 		return this.searchusesreminderCollection;
  | 	}
  | 
  | 	public void setSearchusesreminderCollection(Set<Searchusesreminder> searchusesreminderCollection) {
  | 		this.searchusesreminderCollection = searchusesreminderCollection;
  | 	}
  | 
  | 
  | 	@Embeddable
  | 	public static class PK implements Serializable {
  | 		private long partyidperson2;
  | 		private short sequencenumber;
  | 		private static final long serialVersionUID = 1L;
  | 
  | 		public PK() {
  | 			super();
  | 		}
  | 
  | 		public long getPartyidperson2() {
  | 			return this.partyidperson2;
  | 		}
  | 
  | 		public void setPartyidperson2(long partyidperson2) {
  | 			this.partyidperson2 = partyidperson2;
  | 		}
  | 
  | 		public short getSequencenumber() {
  | 			return this.sequencenumber;
  | 		}
  | 
  | 		public void setSequencenumber(short sequencenumber) {
  | 			this.sequencenumber = sequencenumber;
  | 		}
  | 
  | 		@Override
  | 		public boolean equals(Object o) {
  | 			if (o == this) {
  | 				return true;
  | 			}
  | 			if ( ! (o instanceof PK)) {
  | 				return false;
  | 			}
  | 			PK other = (PK) o;
  | 			return (this.partyidperson2 == other.partyidperson2)
  | 				&& (this.sequencenumber == other.sequencenumber);
  | 		}
  | 
  | 		@Override
  | 		public int hashCode() {
  | 			return ((int) (this.partyidperson2 ^ (this.partyidperson2 >>> 32)))
  | 				^ this.sequencenumber;
  | 		}
  | 
  | 	}
  | 
  | }
  | 

The class Personhasstoredsearches is completely the same

Class SearchUsesReminder:

  | package com.auctonova.ejb.persistence;
  | 
  | import java.io.Serializable;
  | import java.sql.Timestamp;
  | import javax.persistence.Embeddable;
  | import javax.persistence.EmbeddedId;
  | import javax.persistence.Entity;
  | import javax.persistence.JoinColumn;
  | import javax.persistence.JoinColumns;
  | import javax.persistence.ManyToOne;
  | 
  | @Entity
  | public class Searchusesreminder implements Serializable {
  | 	@EmbeddedId
  | 	private Searchusesreminder.PK pk;
  | 
  | 	private Timestamp activeuntil;
  | 
  | 	private Timestamp dateadded;
  | 
  | 	@ManyToOne
  | 	@JoinColumns({
  | 		@JoinColumn(name="sequencenumberreminder", referencedColumnName="sequencenumber"),
  | 		@JoinColumn(name="partyidpersonreminder", referencedColumnName="partyidperson")
  | 	})
  | 	private Personhasstoredreminders personhasstoredreminders;
  | 
  | 	@ManyToOne
  | 	@JoinColumns({
  | 		@JoinColumn(name="partyidpersonsearch", referencedColumnName="partyidperson"),
  | 		@JoinColumn(name="sequencenumbersearch", referencedColumnName="sequencenumber")
  | 	})
  | 	private Personhasstoredsearches personhasstoredsearches;
  | 
  | 	private static final long serialVersionUID = 1L;
  | 
  | 	public Searchusesreminder() {
  | 		super();
  | 	}
  | 
  | 	public Searchusesreminder.PK getPk() {
  | 		return this.pk;
  | 	}
  | 
  | 	public void setPk(Searchusesreminder.PK pk) {
  | 		this.pk = pk;
  | 	}
  | 
  | 	public Timestamp getActiveuntil() {
  | 		return this.activeuntil;
  | 	}
  | 
  | 	public void setActiveuntil(Timestamp activeuntil) {
  | 		this.activeuntil = activeuntil;
  | 	}
  | 
  | 	public Timestamp getDateadded() {
  | 		return this.dateadded;
  | 	}
  | 
  | 	public void setDateadded(Timestamp dateadded) {
  | 		this.dateadded = dateadded;
  | 	}
  | 
  | 	public Personhasstoredreminders getPersonhasstoredreminders() {
  | 		return this.personhasstoredreminders;
  | 	}
  | 
  | 	public void setPersonhasstoredreminders(Personhasstoredreminders personhasstoredreminders) {
  | 		this.personhasstoredreminders = personhasstoredreminders;
  | 	}
  | 
  | 	public Personhasstoredsearches getPersonhasstoredsearches() {
  | 		return this.personhasstoredsearches;
  | 	}
  | 
  | 	public void setPersonhasstoredsearches(Personhasstoredsearches personhasstoredsearches) {
  | 		this.personhasstoredsearches = personhasstoredsearches;
  | 	}
  | 
  | 
  | 	@Embeddable
  | 	public static class PK implements Serializable {
  | 		private short sequencenumbersearch;
  | 		private long partyidpersonsearch;
  | 		private long partyidpersonreminder;
  | 		private short sequencenumberreminder;
  | 		private static final long serialVersionUID = 1L;
  | 
  | 		public PK() {
  | 			super();
  | 		}
  | 
  | 		public short getSequencenumbersearch() {
  | 			return this.sequencenumbersearch;
  | 		}
  | 
  | 		public void setSequencenumbersearch(short sequencenumbersearch) {
  | 			this.sequencenumbersearch = sequencenumbersearch;
  | 		}
  | 
  | 		public long getPartyidpersonsearch() {
  | 			return this.partyidpersonsearch;
  | 		}
  | 
  | 		public void setPartyidpersonsearch(long partyidpersonsearch) {
  | 			this.partyidpersonsearch = partyidpersonsearch;
  | 		}
  | 
  | 		public long getPartyidpersonreminder() {
  | 			return this.partyidpersonreminder;
  | 		}
  | 
  | 		public void setPartyidpersonreminder(long partyidpersonreminder) {
  | 			this.partyidpersonreminder = partyidpersonreminder;
  | 		}
  | 
  | 		public short getSequencenumberreminder() {
  | 			return this.sequencenumberreminder;
  | 		}
  | 
  | 		public void setSequencenumberreminder(short sequencenumberreminder) {
  | 			this.sequencenumberreminder = sequencenumberreminder;
  | 		}
  | 
  | 		@Override
  | 		public boolean equals(Object o) {
  | 			if (o == this) {
  | 				return true;
  | 			}
  | 			if ( ! (o instanceof PK)) {
  | 				return false;
  | 			}
  | 			PK other = (PK) o;
  | 			return (this.sequencenumbersearch == other.sequencenumbersearch)
  | 				&& (this.partyidpersonsearch == other.partyidpersonsearch)
  | 				&& (this.partyidpersonreminder == other.partyidpersonreminder)
  | 				&& (this.sequencenumberreminder == other.sequencenumberreminder);
  | 		}
  | 
  | 		@Override
  | 		public int hashCode() {
  | 			return this.sequencenumbersearch
  | 				^ ((int) (this.partyidpersonsearch ^ (this.partyidpersonsearch >>> 32)))
  | 				^ ((int) (this.partyidpersonreminder ^ (this.partyidpersonreminder >>> 32)))
  | 				^ this.sequencenumberreminder;
  | 		}
  | 
  | 	}
  | 
  | }
  | 

Exception:

  | org.hibernate.AnnotationException: referencedColumnNames(partyidperson, sequencenumber) of com.auctonova.ejb.persistence.Searchusesreminder.personhasstoredsearches referencing com.auctonova.ejb.persistence.Personhasstoredsearches not mapped to a single property
  | 	at org.hibernate.cfg.BinderHelper.createSyntheticPropertyReference(BinderHelper.java:165)
  | 	at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:63)
  | 	at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:428)
  | 	at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:286)
  | 	at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
  | 	at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1233)
  | 	at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
  | 	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:869)
  | 	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:407)
  | 	at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
  | 	at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:246)
  | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  | 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  | 	at java.lang.reflect.Method.invoke(Unknown Source)
  | [....] and many more
  | 

Thank you very much for any hint and best regards,

P.S: The code is completely automatically generated with the Eclipse JPA (DataToolsPlatform 1.5.0)

P.P.S The server is jboss 4.2.1 GA

Thomas

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4079905#4079905

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4079905




More information about the jboss-user mailing list