如何使用Hibernate在数据库表中存储字符串数组?(How to store array of strings in database table using Hibernate?)

编程入门 行业动态 更新时间:2024-10-25 08:21:42
如何使用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.

更多推荐

本文发布于:2023-08-06 23:15:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1457486.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数组   字符串   如何使用   数据库   Hibernate

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!