简体   繁体   English

如何在hbm.xml中的Hibernate中映射Integer数组

[英]How to map Integer array in Hibernate in hbm.xml

I use prosgres sql and the table is like this. 我使用prosgres sql,表是这样的。

CREATE TABLE invoice ( id INTEGER NOT NULL PRIMARY KEY, item_ids INTEGER[] NOT NULL, seller VARCHAR(10) NOT NULL ); 创建表发票(id INTEGER NOT NULL主键,item_ids INTEGER [] NOT NULL,卖方VARCHAR(10)NOT NULL);

Here I want to map the 'item_ids' array to the Integer array (Integer[]) in hbm.xml. 在这里,我想将“ item_ids”数组映射到hbm.xml中的Integer数组(Integer [])。 This Integer array does not have any other references.Only an array Any sample code please. 这个Integer数组没有其他引用。只有一个数组请提供任何示例代码。

You can't map Integer array in Hibernate. 您不能在Hibernate中映射Integer数组。 Use List<Integer> using <list></list> tags. 使用<list></list>标记使用List<Integer>

I think you need to modify your database structure to be as follows: 我认为您需要将数据库结构修改如下:

CREATE TABLE invoice ( id INTEGER NOT NULL PRIMARY KEY, seller VARCHAR(10) NOT NULL);

CREATE TABLE invoice_items ( invoice_id INTEGER NOT NULL, item_id INTEGER NOT NULL);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM