如何使用Hibernate在数据库表中存储字符串数组?(How to store array of strings in database table using Hibernate?)
假设我有array of Strings = {"testUser1", "testUser2", ... , "testUser28"} ,我如何将它存储在oracle数据库中,使用varchar2作为userTableColumn dataType。
我的问题:
我如何使用Hibernate在oracle数据库中存储这个字符串数组(任何例子都会受到高度赞赏)? 什么应该是存储这个字符串数组的数据库列的dataType,现在我把它作为varchar2 ,如果我将它定义为clob然后除非size大于4000 bytes ,它将表现为varchar2 ,大小超过4000字节,它将被转换为clob ?Let's say i have array ofStrings= {"testUser1", "testUser2", ... , "testUser28"}, how do I store this in oracle database, am using varchar2 as dataType for userTableColumn.
My question:
How do I store this array of string, for ex, in oracle Database using Hibernate (any example would be highly appreciated) ? What should be dataType of database column that will store this array of string, right now i have that as varchar2, also if I define it as clob then unless size is greater than 4000 bytes, it would behave as varchar2 and size exceeds 4000 bytes, it would be converted to clob?最满意答案
您的Oracle数据库端应如下所示。
CREATE OR REPLACE TYPE string_array AS VARRAY (30) OF VARCHAR2(1000); CREATE TABLE my_table (my_array string_array);但是不能为Hibernate提供示例。
Your Oracle database end should look like this.
CREATE OR REPLACE TYPE string_array AS VARRAY (30) OF VARCHAR2(1000); CREATE TABLE my_table (my_array string_array);Can't provide example for Hibernate though.
更多推荐
发布评论