I have a JPA @Entity class Place
, with some properties holding some information about a place, such as name of place, description, and URLs of some images.
For the URLs of images, I declare a List<Link>
in my entity.
However, I am getting this error:
Basic attribute type should not be a container.
I tried to remove @Basic
, but the error message is still there. I have no idea why it shows this error.
Any help?
You are most likely missing a relational (like @OneToMany
) annotation and/or @Entity
annotation.
I had a same problem in:
@Entity
public class SomeFee {
@Id
private Long id;
private List<AdditionalFee> additionalFees;
//other fields, getters, setters..
}
class AdditionalFee {
@Id
private int id;
//other fields, getters, setters..
}
additionalFees
was the field causing the problem.
What I was missing and what helped me are the following:
@Entity
annotation on the Generic Type argument ( AdditionalFee
) class;@OneToMany
(or any other type of appropriate relation fitting your case) annotation on the private List<AdditionalFee> additionalFees;
field.So, the working version looked like this:
@Entity
public class SomeFee {
@Id
private Long id;
@OneToMany
private List<AdditionalFee> additionalFees;
//other fields, getters, setters..
}
@Entity
class AdditionalFee {
@Id
private int id;
//other fields, getters, setters..
}
You can also use @ElementCollection
:
@ElementCollection
private List<String> tags;
将列表类型的@basic
更改为@OneToMany
As the message says, @Basic
should not be used for containers (eg Java collections). It is only to be used for a limited list of basic types. Remove the @Basic
annotation on that field.
If, as you say in the question, the error message is still there, you might need to try the following steps in order:
(these are generic steps, which I use when an IDE is generating a compilation error that obviously makes no sense.)
The error seems not have impact on GAE since I can run the app and store data into storage. I guess it's a bug in IntelliJ IDEA and you can simply ignore it.
This can also happen when your class is missing its @Entity annotation. When you get weird warnings like these, sometimes it helps to try and compile and see if the compiler complains.
Or you can mark it as @Transient
if it doesn't exist on DB table.
@Transient
private List<String> authorities = new ArrayList<>();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.