-----MyEntity.java
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="MY_TABLE")
public class MyEntity {
private Long id;
private List<Long> stuff;
public MyEntity() {
//super();
}
@Id @Column(name="ID")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Column(name="STUFF")
public List<Long> getStuff() {
return stuff;
}
public void setStuff(List<Long> stuff) {
this.stuff = stuff;
}
}
-----MyEntity.java--
The SQL for creating the underlying DB stuff is like:
CREATE OR REPLACE TYPE NUM_LIST IS TABLE OF NUMBER;
/
CREATE TABLE MY_TABLE (
"ID" NUMBER NOT NULL,
"STUFF" NUM_LIST
) NESTED TABLE STUFF STORE AS MY_TABLE_STUFF;
I'm using Hibernate as implementation of the Java Persistence API
and I'm getting the following error trying to deplyon deployment:
javax.persistence.PersistenceException:
org.hibernate.MappingException: Could not determine type for:
java.util.List, for columns: [org.hibernate.mapping.Column(STUFF)]
Is it possible to map such nested table type columns? I'm o.k. with
using Hibernate specific solutions.
[1]
<http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28371/adobjcol.htm#i458789>,
<http://www.google.com/search?q=oracle+nested+table>
--
Stanimir
> I'm trying to map an Oracle nested table [1] type column to a
> property of an entity bean class like:
[...]
> The SQL for creating the underlying DB stuff is like:
>
> CREATE OR REPLACE TYPE NUM_LIST IS TABLE OF NUMBER;
> /
>
> CREATE TABLE MY_TABLE (
> "ID" NUMBER NOT NULL,
> "STUFF" NUM_LIST
> ) NESTED TABLE STUFF STORE AS MY_TABLE_STUFF;
>
> I'm using Hibernate as implementation of the Java Persistence API
> and I'm getting the following error trying to deplyon deployment:
>
> javax.persistence.PersistenceException:
> org.hibernate.MappingException: Could not determine type for:
> java.util.List, for columns: [org.hibernate.mapping.Column(STUFF)]
>
> Is it possible to map such nested table type columns? I'm o.k. with
> using Hibernate specific solutions.
[...]
I thought nested tables and variable arrays were accessed using the
getArray() method of java.sql.Array, which is implemented by
oracle.sql.ARRAY. See the JDBC Developer's Guide [1], chapter 16.
Sorry, I know little of Hibernate.
[1]
<http://download.oracle.com/docs/cd/B28359_01/java.111/b31224/oraarr.htm#g1072333>
--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>