maybe someone can tell me why I cant inject Embeded Column to my Facility.class? I want to make a column from ContactPerson.class PrimaryKeys in Facility.class Table, after that I want to make contructor in Facility.class to add ContactPerson. I'm kind new to SpringBoot + Jpa and Vaadin ^^ Here is the error message I get, im sure I overlooking something:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.MappingException: component property not found: id
Caused by: org.hibernate.MappingException: component property not found: id
at org.hibernate.mapping.Component.getProperty(Component.java:274) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final]
Facility.class
@Entity
public class Facility extends BaseEntity {
public Facility(@NotBlank String number, @NotBlank String name, @NotBlank String street, String extraInformation,
@NotBlank String zipcode, @NotBlank String city, **ContactPerson contactPerson**) {
this.number = number;
this.name = name;
this.street = street;
this.extraInformation = extraInformation;
this.zipcode = zipcode;
this.city = city;
**//this.contactPerson = contactPerson;**
}
@NotBlank
@Column(unique = true)
private String number;
@NotBlank
private String name;
@NotBlank
private String street;
private String extraInformation;
@NotBlank
private String zipcode;
@NotBlank
private String city;
@Embedded
@Column(columnDefinition = "contactperson")
private ContactPerson contactPerson;
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getExtraInformation() {
return extraInformation;
}
public void setExtraInformation(String extraInformation) {
this.extraInformation = extraInformation;
}
public String getZipcode() {
return zipcode;
}
public void setZipcode(String zipcode) {
this.zipcode = zipcode;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public ContactPerson getContactPerson() {
return contactPerson;
}
public void setContactPerson(ContactPerson contactPerson) {
this.contactPerson = contactPerson;
}
}
ContactPerson.class
@Embeddable
public class ContactPerson extends BaseEntity {
public ContactPerson(@NotBlank String titel, @NotBlank String firstName, @NotBlank String lastName, String telefon, String mobil, @Email String email) {
this.titel = titel;
this.firstName = firstName;
this.lastName = lastName;
this.telefon = telefon;
this.mobil = mobil;
this.email = email;
}
@NotBlank
private String titel;
@NotBlank
private String firstName;
@NotBlank
private String lastName;
private String telefon;
private String mobil;
@Email
private String email;
public String getTitel() {
return titel;
}
public void setTitel(String titel) {
this.titel = titel;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getTelefon() {
return telefon;
}
public void setTelefon(String telefon) {
this.telefon = telefon;
}
public String getMobil() {
return mobil;
}
public void setMobil(String mobil) {
this.mobil = mobil;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}
BaseEntity.class
public abstract class BaseEntity extends AbstractAggregateRoot<BaseEntity> {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
protected long getId() {
return this.id;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || this.getClass() != o.getClass())
return false;
BaseEntity that = (BaseEntity) o;
return Objects.equals(this.id, that.id);
}
@Override
public int hashCode() {
return Objects.hash(this.id);
}
@Override
public String toString() {
return "BaseEntity{" +
"id=" + this.id +
'}';
}
}