Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate @ElementCollection:使用集合的拥有实体表_Hibernate_Spring Data_Entity_Jpa 2.0 - Fatal编程技术网

Hibernate @ElementCollection:使用集合的拥有实体表

Hibernate @ElementCollection:使用集合的拥有实体表,hibernate,spring-data,entity,jpa-2.0,Hibernate,Spring Data,Entity,Jpa 2.0,我有这个实体: @Entity @Table( name = "Group" ) public class Group implements Serializable { @Id private Long id; @ElementCollection @CollectionTable( name = "Group" )//this sends an exception @Column( name = "places_availables" ) private List<Integer&

我有这个实体:

@Entity
@Table( name = "Group" )
public class Group implements Serializable {

@Id
private Long id;

@ElementCollection
@CollectionTable( name = "Group" )//this sends an exception
@Column( name = "places_availables" )
private List<Integer>       places = new ArrayList<Integer>();
}
@实体
@表(name=“Group”)
公共类组实现可序列化{
@身份证
私人长id;
@元素集合
@CollectionTable(name=“Group”)//这会发送一个异常
@列(name=“places\u availables”)
private List places=new ArrayList();
}
我想知道是否有办法防止Hibernate生成一个新表,而只是在
组中添加一个新列。

非常感谢

我带着一个解决方案回来了,我在保存列表之前将其转换为字符串,并在从数据库检索列表时执行相反的操作


这将如何运作?一个团队可以有很多地方。您如何设想将这些多个关联存储在组表中?在我看来,这个列表可以存储在一行中,如下所示:
[1,2,4,5,6,7]
,但似乎不是这样……因此没有任何方法。甚至将列定义为blob或其他东西。可能有一种方法会违背DB设计的基本原理。您可能可以使用JPA2转换器从字符串列表来回转换