Reputation: 1892
I'm stuck with this error :
org.hibernate.MappingException: Could not determine type for: com.mywebsite.entity.Image, at table: User, for columns: [org.hibernate.mapping.Column(profilePhoto)]
I know it have been asked a lot but i'm stuck with this. It have been trying for hours and I can't find anything that work ...
Here are my 2 classes :
@Entity
public class Image extends com.mywebsite.entity.Entity{
//System
@Id
@GeneratedValue
private int id;
[...]
}
@Entity
public class User extends com.mywebsite.entity.Entity{
//System
@Id
@GeneratedValue
private int id;
[...]
//Data
private Image profilePhoto;
[...]
}
Can someone help me there ?
Upvotes: 1
Views: 9436
Reputation: 753
EDIT:
Try this:
@ManyToOne
@JoinColumn(name="profilephoto_id", foreignKey = @ForeignKey(name = "put_name_here_If_You_HaveAForeignKeyConstraint"))
private Image profilePhoto;
ORIGINAL:
From the docs:
Every non static non transient property (field or method depending on the access type) of an entity is considered persistent, unless you annotate it as
@Transient
.
So Hibernate thinks that field is from the database, and it's trying to find that column in your table. Either that column does not exist and it should, in which case you should have an annotation mapping for it like @Column
; or it doesn't exist on the database and it shouldn't exist, in which case you should use @Transient
like the documentation suggests.
Upvotes: 3