users@glassfish.java.net

Re: JPA and XMLType

From: <glassfish_at_javadesktop.org>
Date: Thu, 10 May 2007 18:26:15 PDT

Some more info for you:

Here is my (simplified) entity definition that reads/writes to the view

@Entity
public class XmlInstance implements Serializable
{

    @Id
    @Column(name = "ID")
    private String id;

    /** The actual string representation of the xml instance */
    @Lob
    @Column(name = "XMLSTRING", columnDefinition = "XMLTYPE NOT NULL")
    private String xmlString;
}

Here is the database table definition. Note: it is not called XMLINSTANCE

CREATE TABLE XMLINST (ID VARCHAR2(255) NOT NULL, XMLSTRING XMLTYPE NOT NULL, PRIMARY KEY (ID))

Here is my sql to create the view that reads/writes to the xmlstring clobval. Note: it is called XMLINSTANCE as I want the EJB entity to map to the view

"create or replace view XMLINSTANCE as select xi.id, xi.xmlstring.getClobval() as XMLSTRING from xmlinst xi"

Hope that helps
Cameron
[Message sent by forum member 'cameronr' (cameronr)]

http://forums.java.net/jive/thread.jspa?messageID=216419