Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » Large objects (BLOB)
Large objects (BLOB) [message #103414] |
Wed, 21 November 2007 10:32 |
Eclipse User |
|
|
|
Originally posted by: akarypid.yahoo.gr
Hi,
I'm trying to persist binary objects using Teneo. What's the suggested
method of doing that? I tried using the EByteArray data type, as it was
the closest one to a BLOB I could find. Here's an example model:
<eClassifiers xsi:type="ecore:EClass" name="Document">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="filename"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="content"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EByteArray"/>
</eClassifiers>
Teneo creates a table "document_content" and creates a row each byte in
the array.
The only relevant documentation I found was:
http://www.elver.org/hibernate/ejb3_features.html#lob_notes
My model is not written as an XML schema. How does this map to a .ecore
specification?
P.S. I use hibernate 3.2.5 and Derby as the database backend.
|
|
| |
Re: Large objects (BLOB) [message #103473 is a reply to message #103430] |
Wed, 21 November 2007 16:34 |
Eclipse User |
|
|
|
Originally posted by: akarypid.yahoo.gr
Ok, I added:
<eAnnotations source="teneo.jpa">
<details key="value" value="@Lob"/>
</eAnnotations>
<eAnnotations source="teneo.jpa">
<details key="value" value="@Column(length=1048576)"/>
</eAnnotations>
Now the database schema creation fails because hibernate tries to create
a column of type "VARCHAR FOR BITDATA" whose maximum length is 32768
bytes. Derby has CLOB / BLOB fields. Does Teneo have any control over
this or is it a hibernate issue?
P.S. the runtime log fails to create table "document" as follows:
2140 [main] DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate - create
table "document" (e_id bigint not null, "dtype" varchar(255) not null,
e_version integer not null, "description" varchar(255), "entrydate"
timestamp, "fileextension" varchar(255), "content" varchar(1048576) for
bit data, "case_documents_e_id" bigint, "case_documents_idx" integer,
econtainer_class varchar(255), e_container varchar(255),
e_container_featureid integer, primary key (e_id))
2156 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate -
Unsuccessful: create table "document" (e_id bigint not null, "dtype"
varchar(255) not null, e_version integer not null, "description"
varchar(255), "entrydate" timestamp, "fileextension" varchar(255),
"content" varchar(1048576) for bit data, "case_documents_e_id" bigint,
"case_documents_idx" integer, econtainer_class varchar(255), e_container
varchar(255), e_container_featureid integer, primary key (e_id))
Martin Taal wrote:
> Hi Alexandros,
> You can set an @Lob annotation in ecore also. See a post on this a few
> days back with the title: [Teneo] Text mapping instead of VarChar
> (although this post talks about the text sql type it also applies to
> your binary blob case).
>
> gr. Martin
>
>
> Alexandros Karypidis wrote:
>> Hi,
>>
>> I'm trying to persist binary objects using Teneo. What's the suggested
>> method of doing that? I tried using the EByteArray data type, as it
>> was the closest one to a BLOB I could find. Here's an example model:
>>
>> <eClassifiers xsi:type="ecore:EClass" name="Document">
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="filename"
>> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="content"
>> eType="ecore:EDataType
>> http://www.eclipse.org/emf/2002/Ecore#//EByteArray"/>
>> </eClassifiers>
>>
>> Teneo creates a table "document_content" and creates a row each byte
>> in the array.
>>
>> The only relevant documentation I found was:
>> http://www.elver.org/hibernate/ejb3_features.html#lob_notes
>> My model is not written as an XML schema. How does this map to a
>> .ecore specification?
>>
>> P.S. I use hibernate 3.2.5 and Derby as the database backend.
>
>
|
|
|
Re: Large objects (BLOB) [message #103488 is a reply to message #103473] |
Wed, 21 November 2007 16:50 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
How does the hbm mapping look like for the content feature? You can see the mapping by doing
getMappingXML on the datastore, you can call this method also when the initialize fails.
gr. Martin
Alexandros Karypidis wrote:
> Ok, I added:
>
> <eAnnotations source="teneo.jpa">
> <details key="value" value="@Lob"/>
> </eAnnotations>
> <eAnnotations source="teneo.jpa">
> <details key="value" value="@Column(length=1048576)"/>
> </eAnnotations>
>
> Now the database schema creation fails because hibernate tries to create
> a column of type "VARCHAR FOR BITDATA" whose maximum length is 32768
> bytes. Derby has CLOB / BLOB fields. Does Teneo have any control over
> this or is it a hibernate issue?
>
> P.S. the runtime log fails to create table "document" as follows:
>
> 2140 [main] DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate - create
> table "document" (e_id bigint not null, "dtype" varchar(255) not null,
> e_version integer not null, "description" varchar(255), "entrydate"
> timestamp, "fileextension" varchar(255), "content" varchar(1048576) for
> bit data, "case_documents_e_id" bigint, "case_documents_idx" integer,
> econtainer_class varchar(255), e_container varchar(255),
> e_container_featureid integer, primary key (e_id))
>
> 2156 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate -
> Unsuccessful: create table "document" (e_id bigint not null, "dtype"
> varchar(255) not null, e_version integer not null, "description"
> varchar(255), "entrydate" timestamp, "fileextension" varchar(255),
> "content" varchar(1048576) for bit data, "case_documents_e_id" bigint,
> "case_documents_idx" integer, econtainer_class varchar(255), e_container
> varchar(255), e_container_featureid integer, primary key (e_id))
>
> Martin Taal wrote:
>
>> Hi Alexandros,
>> You can set an @Lob annotation in ecore also. See a post on this a few
>> days back with the title: [Teneo] Text mapping instead of VarChar
>> (although this post talks about the text sql type it also applies to
>> your binary blob case).
>>
>> gr. Martin
>>
>>
>> Alexandros Karypidis wrote:
>>> Hi,
>>>
>>> I'm trying to persist binary objects using Teneo. What's the
>>> suggested method of doing that? I tried using the EByteArray data
>>> type, as it was the closest one to a BLOB I could find. Here's an
>>> example model:
>>>
>>> <eClassifiers xsi:type="ecore:EClass" name="Document">
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="filename"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="content"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EByteArray"/>
>>> </eClassifiers>
>>>
>>> Teneo creates a table "document_content" and creates a row each byte
>>> in the array.
>>>
>>> The only relevant documentation I found was:
>>> http://www.elver.org/hibernate/ejb3_features.html#lob_notes
>>> My model is not written as an XML schema. How does this map to a
>>> .ecore specification?
>>>
>>> P.S. I use hibernate 3.2.5 and Derby as the database backend.
>>
>>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: Large objects (BLOB) [message #103501 is a reply to message #103488] |
Wed, 21 November 2007 20:58 |
Eclipse User |
|
|
|
Originally posted by: akarypid.yahoo.gr
This is it:
--------------------------------------------------------
....
<property name="content" lazy="false" insert="true" update="true"
not-null="false" unique="false" type="binary">
<column not-null="false" unique="false" name="`content`"
length="1048576"/>
</property>
</class>
--------------------------------------------------------
type="binary" and length="1048576"
I believe hibernate accepts type="blob" and type="clob", which would
probably do what I'd like.
Martin Taal wrote:
> How does the hbm mapping look like for the content feature? You can see
> the mapping by doing getMappingXML on the datastore, you can call this
> method also when the initialize fails.
>
> gr. Martin
>
> Alexandros Karypidis wrote:
>> Ok, I added:
>>
>> <eAnnotations source="teneo.jpa">
>> <details key="value" value="@Lob"/>
>> </eAnnotations>
>> <eAnnotations source="teneo.jpa">
>> <details key="value" value="@Column(length=1048576)"/>
>> </eAnnotations>
>>
>> Now the database schema creation fails because hibernate tries to
>> create a column of type "VARCHAR FOR BITDATA" whose maximum length is
>> 32768 bytes. Derby has CLOB / BLOB fields. Does Teneo have any control
>> over this or is it a hibernate issue?
>>
>> P.S. the runtime log fails to create table "document" as follows:
>>
>> 2140 [main] DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate - create
>> table "document" (e_id bigint not null, "dtype" varchar(255) not null,
>> e_version integer not null, "description" varchar(255), "entrydate"
>> timestamp, "fileextension" varchar(255), "content" varchar(1048576)
>> for bit data, "case_documents_e_id" bigint, "case_documents_idx"
>> integer, econtainer_class varchar(255), e_container varchar(255),
>> e_container_featureid integer, primary key (e_id))
>>
>> 2156 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate -
>> Unsuccessful: create table "document" (e_id bigint not null, "dtype"
>> varchar(255) not null, e_version integer not null, "description"
>> varchar(255), "entrydate" timestamp, "fileextension" varchar(255),
>> "content" varchar(1048576) for bit data, "case_documents_e_id" bigint,
>> "case_documents_idx" integer, econtainer_class varchar(255),
>> e_container varchar(255), e_container_featureid integer, primary key
>> (e_id))
>>
>> Martin Taal wrote:
>>
>>> Hi Alexandros,
>>> You can set an @Lob annotation in ecore also. See a post on this a
>>> few days back with the title: [Teneo] Text mapping instead of VarChar
>>> (although this post talks about the text sql type it also applies to
>>> your binary blob case).
>>>
>>> gr. Martin
>>>
>>>
>>> Alexandros Karypidis wrote:
>>>> Hi,
>>>>
>>>> I'm trying to persist binary objects using Teneo. What's the
>>>> suggested method of doing that? I tried using the EByteArray data
>>>> type, as it was the closest one to a BLOB I could find. Here's an
>>>> example model:
>>>>
>>>> <eClassifiers xsi:type="ecore:EClass" name="Document">
>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="filename"
>>>> eType="ecore:EDataType
>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="content"
>>>> eType="ecore:EDataType
>>>> http://www.eclipse.org/emf/2002/Ecore#//EByteArray"/>
>>>> </eClassifiers>
>>>>
>>>> Teneo creates a table "document_content" and creates a row each byte
>>>> in the array.
>>>>
>>>> The only relevant documentation I found was:
>>>> http://www.elver.org/hibernate/ejb3_features.html#lob_notes
>>>> My model is not written as an XML schema. How does this map to a
>>>> .ecore specification?
>>>>
>>>> P.S. I use hibernate 3.2.5 and Derby as the database backend.
>>>
>>>
>
>
|
|
|
Re: Large objects (BLOB) [message #103534 is a reply to message #103501] |
Wed, 21 November 2007 22:09 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
You can try the following annotation to set the type to blob:
@Type(type="blob")
the other two annotations (lob and column) should remain there.
Btw, you can enter multiple annotation in one eannotation (the value of the details is opened in a
multi-line editor).
gr. Martin
Alexandros Karypidis wrote:
> This is it:
>
> --------------------------------------------------------
> ....
> <property name="content" lazy="false" insert="true" update="true"
> not-null="false" unique="false" type="binary">
> <column not-null="false" unique="false" name="`content`"
> length="1048576"/>
> </property>
> </class>
> --------------------------------------------------------
>
> type="binary" and length="1048576"
>
> I believe hibernate accepts type="blob" and type="clob", which would
> probably do what I'd like.
>
> Martin Taal wrote:
>
>> How does the hbm mapping look like for the content feature? You can
>> see the mapping by doing getMappingXML on the datastore, you can call
>> this method also when the initialize fails.
>>
>> gr. Martin
>>
>> Alexandros Karypidis wrote:
>>> Ok, I added:
>>>
>>> <eAnnotations source="teneo.jpa">
>>> <details key="value" value="@Lob"/>
>>> </eAnnotations>
>>> <eAnnotations source="teneo.jpa">
>>> <details key="value" value="@Column(length=1048576)"/>
>>> </eAnnotations>
>>>
>>> Now the database schema creation fails because hibernate tries to
>>> create a column of type "VARCHAR FOR BITDATA" whose maximum length is
>>> 32768 bytes. Derby has CLOB / BLOB fields. Does Teneo have any
>>> control over this or is it a hibernate issue?
>>>
>>> P.S. the runtime log fails to create table "document" as follows:
>>>
>>> 2140 [main] DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate - create
>>> table "document" (e_id bigint not null, "dtype" varchar(255) not
>>> null, e_version integer not null, "description" varchar(255),
>>> "entrydate" timestamp, "fileextension" varchar(255), "content"
>>> varchar(1048576) for bit data, "case_documents_e_id" bigint,
>>> "case_documents_idx" integer, econtainer_class varchar(255),
>>> e_container varchar(255), e_container_featureid integer, primary key
>>> (e_id))
>>>
>>> 2156 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate -
>>> Unsuccessful: create table "document" (e_id bigint not null, "dtype"
>>> varchar(255) not null, e_version integer not null, "description"
>>> varchar(255), "entrydate" timestamp, "fileextension" varchar(255),
>>> "content" varchar(1048576) for bit data, "case_documents_e_id"
>>> bigint, "case_documents_idx" integer, econtainer_class varchar(255),
>>> e_container varchar(255), e_container_featureid integer, primary key
>>> (e_id))
>>>
>>> Martin Taal wrote:
>>>
>>>> Hi Alexandros,
>>>> You can set an @Lob annotation in ecore also. See a post on this a
>>>> few days back with the title: [Teneo] Text mapping instead of VarChar
>>>> (although this post talks about the text sql type it also applies to
>>>> your binary blob case).
>>>>
>>>> gr. Martin
>>>>
>>>>
>>>> Alexandros Karypidis wrote:
>>>>> Hi,
>>>>>
>>>>> I'm trying to persist binary objects using Teneo. What's the
>>>>> suggested method of doing that? I tried using the EByteArray data
>>>>> type, as it was the closest one to a BLOB I could find. Here's an
>>>>> example model:
>>>>>
>>>>> <eClassifiers xsi:type="ecore:EClass" name="Document">
>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>>>>> name="filename" eType="ecore:EDataType
>>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="content"
>>>>> eType="ecore:EDataType
>>>>> http://www.eclipse.org/emf/2002/Ecore#//EByteArray"/>
>>>>> </eClassifiers>
>>>>>
>>>>> Teneo creates a table "document_content" and creates a row each
>>>>> byte in the array.
>>>>>
>>>>> The only relevant documentation I found was:
>>>>> http://www.elver.org/hibernate/ejb3_features.html#lob_notes
>>>>> My model is not written as an XML schema. How does this map to a
>>>>> .ecore specification?
>>>>>
>>>>> P.S. I use hibernate 3.2.5 and Derby as the database backend.
>>>>
>>>>
>>
>>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: Large objects (BLOB) [message #103593 is a reply to message #103534] |
Thu, 22 November 2007 12:41 |
Eclipse User |
|
|
|
Originally posted by: akarypid.yahoo.gr
Yep, works like a charm! :-)
P.S. If you've been searching the archives, the summary is:
1) Add an EDataType for java.sql.Blob in your ecore:
<eClassifiers xsi:type="ecore:EDataType" name="Blob"
instanceClassName="java.sql.Blob"/>
2) In the attribute of type Blob, add "teneo.jpa" annotations as follows
in your ecore:
....
<eStructuralFeatures xsi:type="ecore:EAttribute" name="content"
eType="#//Blob">
<eAnnotations source="teneo.jpa">
<details key="value"
value=" @Lob
@Column(length=1048576)
&# xA;@Type(type="blob") "/>
</eAnnotations>
</eStructuralFeatures>
....
Notice the 1MB column length if you copy-paste. Change it to what you need.
3) Use the blob as you would with hibernate. For instance:
Document doc = SolonFactory.eINSTANCE.createDocument();
Blob blob = Hibernate.createBlob(new byte[] { 1, 2, 3, 4 });
doc.setContent(blob);
Martin Taal wrote:
> You can try the following annotation to set the type to blob:
> @Type(type="blob")
> the other two annotations (lob and column) should remain there.
> Btw, you can enter multiple annotation in one eannotation (the value of
> the details is opened in a multi-line editor).
>
> gr. Martin
>
> Alexandros Karypidis wrote:
>> This is it:
>>
>> --------------------------------------------------------
>> ....
>> <property name="content" lazy="false" insert="true" update="true"
>> not-null="false" unique="false" type="binary">
>> <column not-null="false" unique="false" name="`content`"
>> length="1048576"/>
>> </property>
>> </class>
>> --------------------------------------------------------
>>
>> type="binary" and length="1048576"
>>
>> I believe hibernate accepts type="blob" and type="clob", which would
>> probably do what I'd like.
>>
>> Martin Taal wrote:
>>
>>> How does the hbm mapping look like for the content feature? You can
>>> see the mapping by doing getMappingXML on the datastore, you can call
>>> this method also when the initialize fails.
>>>
>>> gr. Martin
>>>
>>> Alexandros Karypidis wrote:
>>>> Ok, I added:
>>>>
>>>> <eAnnotations source="teneo.jpa">
>>>> <details key="value" value="@Lob"/>
>>>> </eAnnotations>
>>>> <eAnnotations source="teneo.jpa">
>>>> <details key="value" value="@Column(length=1048576)"/>
>>>> </eAnnotations>
>>>>
>>>> Now the database schema creation fails because hibernate tries to
>>>> create a column of type "VARCHAR FOR BITDATA" whose maximum length
>>>> is 32768 bytes. Derby has CLOB / BLOB fields. Does Teneo have any
>>>> control over this or is it a hibernate issue?
>>>>
>>>> P.S. the runtime log fails to create table "document" as follows:
>>>>
>>>> 2140 [main] DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate - create
>>>> table "document" (e_id bigint not null, "dtype" varchar(255) not
>>>> null, e_version integer not null, "description" varchar(255),
>>>> "entrydate" timestamp, "fileextension" varchar(255), "content"
>>>> varchar(1048576) for bit data, "case_documents_e_id" bigint,
>>>> "case_documents_idx" integer, econtainer_class varchar(255),
>>>> e_container varchar(255), e_container_featureid integer, primary key
>>>> (e_id))
>>>>
>>>> 2156 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate -
>>>> Unsuccessful: create table "document" (e_id bigint not null, "dtype"
>>>> varchar(255) not null, e_version integer not null, "description"
>>>> varchar(255), "entrydate" timestamp, "fileextension" varchar(255),
>>>> "content" varchar(1048576) for bit data, "case_documents_e_id"
>>>> bigint, "case_documents_idx" integer, econtainer_class varchar(255),
>>>> e_container varchar(255), e_container_featureid integer, primary key
>>>> (e_id))
>>>>
>>>> Martin Taal wrote:
>>>>
>>>>> Hi Alexandros,
>>>>> You can set an @Lob annotation in ecore also. See a post on this a
>>>>> few days back with the title: [Teneo] Text mapping instead of VarChar
>>>>> (although this post talks about the text sql type it also applies
>>>>> to your binary blob case).
>>>>>
>>>>> gr. Martin
>>>>>
>>>>>
>>>>> Alexandros Karypidis wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I'm trying to persist binary objects using Teneo. What's the
>>>>>> suggested method of doing that? I tried using the EByteArray data
>>>>>> type, as it was the closest one to a BLOB I could find. Here's an
>>>>>> example model:
>>>>>>
>>>>>> <eClassifiers xsi:type="ecore:EClass" name="Document">
>>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>>>>>> name="filename" eType="ecore:EDataType
>>>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>>>>>> name="content" eType="ecore:EDataType
>>>>>> http://www.eclipse.org/emf/2002/Ecore#//EByteArray"/>
>>>>>> </eClassifiers>
>>>>>>
>>>>>> Teneo creates a table "document_content" and creates a row each
>>>>>> byte in the array.
>>>>>>
>>>>>> The only relevant documentation I found was:
>>>>>> http://www.elver.org/hibernate/ejb3_features.html#lob_notes
>>>>>> My model is not written as an XML schema. How does this map to a
>>>>>> .ecore specification?
>>>>>>
>>>>>> P.S. I use hibernate 3.2.5 and Derby as the database backend.
>>>>>
>>>>>
>>>
>>>
>
>
|
|
|
Re: Large objects (BLOB) [message #103619 is a reply to message #103593] |
Thu, 22 November 2007 12:49 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Thanks for the summary I will add it to the docs in the next build.
gr. Martin
Alexandros Karypidis wrote:
> Yep, works like a charm! :-)
>
> P.S. If you've been searching the archives, the summary is:
>
> 1) Add an EDataType for java.sql.Blob in your ecore:
>
> <eClassifiers xsi:type="ecore:EDataType" name="Blob"
> instanceClassName="java.sql.Blob"/>
>
> 2) In the attribute of type Blob, add "teneo.jpa" annotations as follows
> in your ecore:
>
> ....
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="content"
> eType="#//Blob">
> <eAnnotations source="teneo.jpa">
> <details key="value"
> value=" @Lob
@Column(length=1048576)
&# xA;@Type(type="blob") "/>
>
> </eAnnotations>
> </eStructuralFeatures>
> ....
>
> Notice the 1MB column length if you copy-paste. Change it to what you need.
>
> 3) Use the blob as you would with hibernate. For instance:
>
> Document doc = SolonFactory.eINSTANCE.createDocument();
> Blob blob = Hibernate.createBlob(new byte[] { 1, 2, 3, 4 });
> doc.setContent(blob);
>
> Martin Taal wrote:
>
>> You can try the following annotation to set the type to blob:
>> @Type(type="blob")
>> the other two annotations (lob and column) should remain there.
>> Btw, you can enter multiple annotation in one eannotation (the value
>> of the details is opened in a multi-line editor).
>>
>> gr. Martin
>>
>> Alexandros Karypidis wrote:
>>> This is it:
>>>
>>> --------------------------------------------------------
>>> ....
>>> <property name="content" lazy="false" insert="true" update="true"
>>> not-null="false" unique="false" type="binary">
>>> <column not-null="false" unique="false" name="`content`"
>>> length="1048576"/>
>>> </property>
>>> </class>
>>> --------------------------------------------------------
>>>
>>> type="binary" and length="1048576"
>>>
>>> I believe hibernate accepts type="blob" and type="clob", which would
>>> probably do what I'd like.
>>>
>>> Martin Taal wrote:
>>>
>>>> How does the hbm mapping look like for the content feature? You can
>>>> see the mapping by doing getMappingXML on the datastore, you can
>>>> call this method also when the initialize fails.
>>>>
>>>> gr. Martin
>>>>
>>>> Alexandros Karypidis wrote:
>>>>> Ok, I added:
>>>>>
>>>>> <eAnnotations source="teneo.jpa">
>>>>> <details key="value" value="@Lob"/>
>>>>> </eAnnotations>
>>>>> <eAnnotations source="teneo.jpa">
>>>>> <details key="value" value="@Column(length=1048576)"/>
>>>>> </eAnnotations>
>>>>>
>>>>> Now the database schema creation fails because hibernate tries to
>>>>> create a column of type "VARCHAR FOR BITDATA" whose maximum length
>>>>> is 32768 bytes. Derby has CLOB / BLOB fields. Does Teneo have any
>>>>> control over this or is it a hibernate issue?
>>>>>
>>>>> P.S. the runtime log fails to create table "document" as follows:
>>>>>
>>>>> 2140 [main] DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate - create
>>>>> table "document" (e_id bigint not null, "dtype" varchar(255) not
>>>>> null, e_version integer not null, "description" varchar(255),
>>>>> "entrydate" timestamp, "fileextension" varchar(255), "content"
>>>>> varchar(1048576) for bit data, "case_documents_e_id" bigint,
>>>>> "case_documents_idx" integer, econtainer_class varchar(255),
>>>>> e_container varchar(255), e_container_featureid integer, primary
>>>>> key (e_id))
>>>>>
>>>>> 2156 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate -
>>>>> Unsuccessful: create table "document" (e_id bigint not null,
>>>>> "dtype" varchar(255) not null, e_version integer not null,
>>>>> "description" varchar(255), "entrydate" timestamp, "fileextension"
>>>>> varchar(255), "content" varchar(1048576) for bit data,
>>>>> "case_documents_e_id" bigint, "case_documents_idx" integer,
>>>>> econtainer_class varchar(255), e_container varchar(255),
>>>>> e_container_featureid integer, primary key (e_id))
>>>>>
>>>>> Martin Taal wrote:
>>>>>
>>>>>> Hi Alexandros,
>>>>>> You can set an @Lob annotation in ecore also. See a post on this a
>>>>>> few days back with the title: [Teneo] Text mapping instead of VarChar
>>>>>> (although this post talks about the text sql type it also applies
>>>>>> to your binary blob case).
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>>
>>>>>> Alexandros Karypidis wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> I'm trying to persist binary objects using Teneo. What's the
>>>>>>> suggested method of doing that? I tried using the EByteArray data
>>>>>>> type, as it was the closest one to a BLOB I could find. Here's an
>>>>>>> example model:
>>>>>>>
>>>>>>> <eClassifiers xsi:type="ecore:EClass" name="Document">
>>>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>>>>>>> name="filename" eType="ecore:EDataType
>>>>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>>>>>>> name="content" eType="ecore:EDataType
>>>>>>> http://www.eclipse.org/emf/2002/Ecore#//EByteArray"/>
>>>>>>> </eClassifiers>
>>>>>>>
>>>>>>> Teneo creates a table "document_content" and creates a row each
>>>>>>> byte in the array.
>>>>>>>
>>>>>>> The only relevant documentation I found was:
>>>>>>> http://www.elver.org/hibernate/ejb3_features.html#lob_notes
>>>>>>> My model is not written as an XML schema. How does this map to a
>>>>>>> .ecore specification?
>>>>>>>
>>>>>>> P.S. I use hibernate 3.2.5 and Derby as the database backend.
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
| |
Re: Large objects (BLOB) [message #612638 is a reply to message #103430] |
Wed, 21 November 2007 16:34 |
Alex Mising name Messages: 149 Registered: March 2010 |
Senior Member |
|
|
Ok, I added:
<eAnnotations source="teneo.jpa">
<details key="value" value="@Lob"/>
</eAnnotations>
<eAnnotations source="teneo.jpa">
<details key="value" value="@Column(length=1048576)"/>
</eAnnotations>
Now the database schema creation fails because hibernate tries to create
a column of type "VARCHAR FOR BITDATA" whose maximum length is 32768
bytes. Derby has CLOB / BLOB fields. Does Teneo have any control over
this or is it a hibernate issue?
P.S. the runtime log fails to create table "document" as follows:
2140 [main] DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate - create
table "document" (e_id bigint not null, "dtype" varchar(255) not null,
e_version integer not null, "description" varchar(255), "entrydate"
timestamp, "fileextension" varchar(255), "content" varchar(1048576) for
bit data, "case_documents_e_id" bigint, "case_documents_idx" integer,
econtainer_class varchar(255), e_container varchar(255),
e_container_featureid integer, primary key (e_id))
2156 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate -
Unsuccessful: create table "document" (e_id bigint not null, "dtype"
varchar(255) not null, e_version integer not null, "description"
varchar(255), "entrydate" timestamp, "fileextension" varchar(255),
"content" varchar(1048576) for bit data, "case_documents_e_id" bigint,
"case_documents_idx" integer, econtainer_class varchar(255), e_container
varchar(255), e_container_featureid integer, primary key (e_id))
Martin Taal wrote:
> Hi Alexandros,
> You can set an @Lob annotation in ecore also. See a post on this a few
> days back with the title: [Teneo] Text mapping instead of VarChar
> (although this post talks about the text sql type it also applies to
> your binary blob case).
>
> gr. Martin
>
>
> Alexandros Karypidis wrote:
>> Hi,
>>
>> I'm trying to persist binary objects using Teneo. What's the suggested
>> method of doing that? I tried using the EByteArray data type, as it
>> was the closest one to a BLOB I could find. Here's an example model:
>>
>> <eClassifiers xsi:type="ecore:EClass" name="Document">
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="filename"
>> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="content"
>> eType="ecore:EDataType
>> http://www.eclipse.org/emf/2002/Ecore#//EByteArray"/>
>> </eClassifiers>
>>
>> Teneo creates a table "document_content" and creates a row each byte
>> in the array.
>>
>> The only relevant documentation I found was:
>> http://www.elver.org/hibernate/ejb3_features.html#lob_notes
>> My model is not written as an XML schema. How does this map to a
>> .ecore specification?
>>
>> P.S. I use hibernate 3.2.5 and Derby as the database backend.
>
>
|
|
|
Re: Large objects (BLOB) [message #612639 is a reply to message #103473] |
Wed, 21 November 2007 16:50 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
How does the hbm mapping look like for the content feature? You can see the mapping by doing
getMappingXML on the datastore, you can call this method also when the initialize fails.
gr. Martin
Alexandros Karypidis wrote:
> Ok, I added:
>
> <eAnnotations source="teneo.jpa">
> <details key="value" value="@Lob"/>
> </eAnnotations>
> <eAnnotations source="teneo.jpa">
> <details key="value" value="@Column(length=1048576)"/>
> </eAnnotations>
>
> Now the database schema creation fails because hibernate tries to create
> a column of type "VARCHAR FOR BITDATA" whose maximum length is 32768
> bytes. Derby has CLOB / BLOB fields. Does Teneo have any control over
> this or is it a hibernate issue?
>
> P.S. the runtime log fails to create table "document" as follows:
>
> 2140 [main] DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate - create
> table "document" (e_id bigint not null, "dtype" varchar(255) not null,
> e_version integer not null, "description" varchar(255), "entrydate"
> timestamp, "fileextension" varchar(255), "content" varchar(1048576) for
> bit data, "case_documents_e_id" bigint, "case_documents_idx" integer,
> econtainer_class varchar(255), e_container varchar(255),
> e_container_featureid integer, primary key (e_id))
>
> 2156 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate -
> Unsuccessful: create table "document" (e_id bigint not null, "dtype"
> varchar(255) not null, e_version integer not null, "description"
> varchar(255), "entrydate" timestamp, "fileextension" varchar(255),
> "content" varchar(1048576) for bit data, "case_documents_e_id" bigint,
> "case_documents_idx" integer, econtainer_class varchar(255), e_container
> varchar(255), e_container_featureid integer, primary key (e_id))
>
> Martin Taal wrote:
>
>> Hi Alexandros,
>> You can set an @Lob annotation in ecore also. See a post on this a few
>> days back with the title: [Teneo] Text mapping instead of VarChar
>> (although this post talks about the text sql type it also applies to
>> your binary blob case).
>>
>> gr. Martin
>>
>>
>> Alexandros Karypidis wrote:
>>> Hi,
>>>
>>> I'm trying to persist binary objects using Teneo. What's the
>>> suggested method of doing that? I tried using the EByteArray data
>>> type, as it was the closest one to a BLOB I could find. Here's an
>>> example model:
>>>
>>> <eClassifiers xsi:type="ecore:EClass" name="Document">
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="filename"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="content"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EByteArray"/>
>>> </eClassifiers>
>>>
>>> Teneo creates a table "document_content" and creates a row each byte
>>> in the array.
>>>
>>> The only relevant documentation I found was:
>>> http://www.elver.org/hibernate/ejb3_features.html#lob_notes
>>> My model is not written as an XML schema. How does this map to a
>>> .ecore specification?
>>>
>>> P.S. I use hibernate 3.2.5 and Derby as the database backend.
>>
>>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: Large objects (BLOB) [message #612641 is a reply to message #103488] |
Wed, 21 November 2007 20:58 |
Alex Mising name Messages: 149 Registered: March 2010 |
Senior Member |
|
|
This is it:
--------------------------------------------------------
....
<property name="content" lazy="false" insert="true" update="true"
not-null="false" unique="false" type="binary">
<column not-null="false" unique="false" name="`content`"
length="1048576"/>
</property>
</class>
--------------------------------------------------------
type="binary" and length="1048576"
I believe hibernate accepts type="blob" and type="clob", which would
probably do what I'd like.
Martin Taal wrote:
> How does the hbm mapping look like for the content feature? You can see
> the mapping by doing getMappingXML on the datastore, you can call this
> method also when the initialize fails.
>
> gr. Martin
>
> Alexandros Karypidis wrote:
>> Ok, I added:
>>
>> <eAnnotations source="teneo.jpa">
>> <details key="value" value="@Lob"/>
>> </eAnnotations>
>> <eAnnotations source="teneo.jpa">
>> <details key="value" value="@Column(length=1048576)"/>
>> </eAnnotations>
>>
>> Now the database schema creation fails because hibernate tries to
>> create a column of type "VARCHAR FOR BITDATA" whose maximum length is
>> 32768 bytes. Derby has CLOB / BLOB fields. Does Teneo have any control
>> over this or is it a hibernate issue?
>>
>> P.S. the runtime log fails to create table "document" as follows:
>>
>> 2140 [main] DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate - create
>> table "document" (e_id bigint not null, "dtype" varchar(255) not null,
>> e_version integer not null, "description" varchar(255), "entrydate"
>> timestamp, "fileextension" varchar(255), "content" varchar(1048576)
>> for bit data, "case_documents_e_id" bigint, "case_documents_idx"
>> integer, econtainer_class varchar(255), e_container varchar(255),
>> e_container_featureid integer, primary key (e_id))
>>
>> 2156 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate -
>> Unsuccessful: create table "document" (e_id bigint not null, "dtype"
>> varchar(255) not null, e_version integer not null, "description"
>> varchar(255), "entrydate" timestamp, "fileextension" varchar(255),
>> "content" varchar(1048576) for bit data, "case_documents_e_id" bigint,
>> "case_documents_idx" integer, econtainer_class varchar(255),
>> e_container varchar(255), e_container_featureid integer, primary key
>> (e_id))
>>
>> Martin Taal wrote:
>>
>>> Hi Alexandros,
>>> You can set an @Lob annotation in ecore also. See a post on this a
>>> few days back with the title: [Teneo] Text mapping instead of VarChar
>>> (although this post talks about the text sql type it also applies to
>>> your binary blob case).
>>>
>>> gr. Martin
>>>
>>>
>>> Alexandros Karypidis wrote:
>>>> Hi,
>>>>
>>>> I'm trying to persist binary objects using Teneo. What's the
>>>> suggested method of doing that? I tried using the EByteArray data
>>>> type, as it was the closest one to a BLOB I could find. Here's an
>>>> example model:
>>>>
>>>> <eClassifiers xsi:type="ecore:EClass" name="Document">
>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="filename"
>>>> eType="ecore:EDataType
>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="content"
>>>> eType="ecore:EDataType
>>>> http://www.eclipse.org/emf/2002/Ecore#//EByteArray"/>
>>>> </eClassifiers>
>>>>
>>>> Teneo creates a table "document_content" and creates a row each byte
>>>> in the array.
>>>>
>>>> The only relevant documentation I found was:
>>>> http://www.elver.org/hibernate/ejb3_features.html#lob_notes
>>>> My model is not written as an XML schema. How does this map to a
>>>> .ecore specification?
>>>>
>>>> P.S. I use hibernate 3.2.5 and Derby as the database backend.
>>>
>>>
>
>
|
|
|
Re: Large objects (BLOB) [message #612645 is a reply to message #103501] |
Wed, 21 November 2007 22:09 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
You can try the following annotation to set the type to blob:
@Type(type="blob")
the other two annotations (lob and column) should remain there.
Btw, you can enter multiple annotation in one eannotation (the value of the details is opened in a
multi-line editor).
gr. Martin
Alexandros Karypidis wrote:
> This is it:
>
> --------------------------------------------------------
> ....
> <property name="content" lazy="false" insert="true" update="true"
> not-null="false" unique="false" type="binary">
> <column not-null="false" unique="false" name="`content`"
> length="1048576"/>
> </property>
> </class>
> --------------------------------------------------------
>
> type="binary" and length="1048576"
>
> I believe hibernate accepts type="blob" and type="clob", which would
> probably do what I'd like.
>
> Martin Taal wrote:
>
>> How does the hbm mapping look like for the content feature? You can
>> see the mapping by doing getMappingXML on the datastore, you can call
>> this method also when the initialize fails.
>>
>> gr. Martin
>>
>> Alexandros Karypidis wrote:
>>> Ok, I added:
>>>
>>> <eAnnotations source="teneo.jpa">
>>> <details key="value" value="@Lob"/>
>>> </eAnnotations>
>>> <eAnnotations source="teneo.jpa">
>>> <details key="value" value="@Column(length=1048576)"/>
>>> </eAnnotations>
>>>
>>> Now the database schema creation fails because hibernate tries to
>>> create a column of type "VARCHAR FOR BITDATA" whose maximum length is
>>> 32768 bytes. Derby has CLOB / BLOB fields. Does Teneo have any
>>> control over this or is it a hibernate issue?
>>>
>>> P.S. the runtime log fails to create table "document" as follows:
>>>
>>> 2140 [main] DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate - create
>>> table "document" (e_id bigint not null, "dtype" varchar(255) not
>>> null, e_version integer not null, "description" varchar(255),
>>> "entrydate" timestamp, "fileextension" varchar(255), "content"
>>> varchar(1048576) for bit data, "case_documents_e_id" bigint,
>>> "case_documents_idx" integer, econtainer_class varchar(255),
>>> e_container varchar(255), e_container_featureid integer, primary key
>>> (e_id))
>>>
>>> 2156 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate -
>>> Unsuccessful: create table "document" (e_id bigint not null, "dtype"
>>> varchar(255) not null, e_version integer not null, "description"
>>> varchar(255), "entrydate" timestamp, "fileextension" varchar(255),
>>> "content" varchar(1048576) for bit data, "case_documents_e_id"
>>> bigint, "case_documents_idx" integer, econtainer_class varchar(255),
>>> e_container varchar(255), e_container_featureid integer, primary key
>>> (e_id))
>>>
>>> Martin Taal wrote:
>>>
>>>> Hi Alexandros,
>>>> You can set an @Lob annotation in ecore also. See a post on this a
>>>> few days back with the title: [Teneo] Text mapping instead of VarChar
>>>> (although this post talks about the text sql type it also applies to
>>>> your binary blob case).
>>>>
>>>> gr. Martin
>>>>
>>>>
>>>> Alexandros Karypidis wrote:
>>>>> Hi,
>>>>>
>>>>> I'm trying to persist binary objects using Teneo. What's the
>>>>> suggested method of doing that? I tried using the EByteArray data
>>>>> type, as it was the closest one to a BLOB I could find. Here's an
>>>>> example model:
>>>>>
>>>>> <eClassifiers xsi:type="ecore:EClass" name="Document">
>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>>>>> name="filename" eType="ecore:EDataType
>>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="content"
>>>>> eType="ecore:EDataType
>>>>> http://www.eclipse.org/emf/2002/Ecore#//EByteArray"/>
>>>>> </eClassifiers>
>>>>>
>>>>> Teneo creates a table "document_content" and creates a row each
>>>>> byte in the array.
>>>>>
>>>>> The only relevant documentation I found was:
>>>>> http://www.elver.org/hibernate/ejb3_features.html#lob_notes
>>>>> My model is not written as an XML schema. How does this map to a
>>>>> .ecore specification?
>>>>>
>>>>> P.S. I use hibernate 3.2.5 and Derby as the database backend.
>>>>
>>>>
>>
>>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: Large objects (BLOB) [message #612650 is a reply to message #103534] |
Thu, 22 November 2007 12:41 |
Alex Mising name Messages: 149 Registered: March 2010 |
Senior Member |
|
|
Yep, works like a charm! :-)
P.S. If you've been searching the archives, the summary is:
1) Add an EDataType for java.sql.Blob in your ecore:
<eClassifiers xsi:type="ecore:EDataType" name="Blob"
instanceClassName="java.sql.Blob"/>
2) In the attribute of type Blob, add "teneo.jpa" annotations as follows
in your ecore:
....
<eStructuralFeatures xsi:type="ecore:EAttribute" name="content"
eType="#//Blob">
<eAnnotations source="teneo.jpa">
<details key="value"
value=" @Lob
@Column(length=1048576)
&# xA;@Type(type="blob") "/>
</eAnnotations>
</eStructuralFeatures>
....
Notice the 1MB column length if you copy-paste. Change it to what you need.
3) Use the blob as you would with hibernate. For instance:
Document doc = SolonFactory.eINSTANCE.createDocument();
Blob blob = Hibernate.createBlob(new byte[] { 1, 2, 3, 4 });
doc.setContent(blob);
Martin Taal wrote:
> You can try the following annotation to set the type to blob:
> @Type(type="blob")
> the other two annotations (lob and column) should remain there.
> Btw, you can enter multiple annotation in one eannotation (the value of
> the details is opened in a multi-line editor).
>
> gr. Martin
>
> Alexandros Karypidis wrote:
>> This is it:
>>
>> --------------------------------------------------------
>> ....
>> <property name="content" lazy="false" insert="true" update="true"
>> not-null="false" unique="false" type="binary">
>> <column not-null="false" unique="false" name="`content`"
>> length="1048576"/>
>> </property>
>> </class>
>> --------------------------------------------------------
>>
>> type="binary" and length="1048576"
>>
>> I believe hibernate accepts type="blob" and type="clob", which would
>> probably do what I'd like.
>>
>> Martin Taal wrote:
>>
>>> How does the hbm mapping look like for the content feature? You can
>>> see the mapping by doing getMappingXML on the datastore, you can call
>>> this method also when the initialize fails.
>>>
>>> gr. Martin
>>>
>>> Alexandros Karypidis wrote:
>>>> Ok, I added:
>>>>
>>>> <eAnnotations source="teneo.jpa">
>>>> <details key="value" value="@Lob"/>
>>>> </eAnnotations>
>>>> <eAnnotations source="teneo.jpa">
>>>> <details key="value" value="@Column(length=1048576)"/>
>>>> </eAnnotations>
>>>>
>>>> Now the database schema creation fails because hibernate tries to
>>>> create a column of type "VARCHAR FOR BITDATA" whose maximum length
>>>> is 32768 bytes. Derby has CLOB / BLOB fields. Does Teneo have any
>>>> control over this or is it a hibernate issue?
>>>>
>>>> P.S. the runtime log fails to create table "document" as follows:
>>>>
>>>> 2140 [main] DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate - create
>>>> table "document" (e_id bigint not null, "dtype" varchar(255) not
>>>> null, e_version integer not null, "description" varchar(255),
>>>> "entrydate" timestamp, "fileextension" varchar(255), "content"
>>>> varchar(1048576) for bit data, "case_documents_e_id" bigint,
>>>> "case_documents_idx" integer, econtainer_class varchar(255),
>>>> e_container varchar(255), e_container_featureid integer, primary key
>>>> (e_id))
>>>>
>>>> 2156 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate -
>>>> Unsuccessful: create table "document" (e_id bigint not null, "dtype"
>>>> varchar(255) not null, e_version integer not null, "description"
>>>> varchar(255), "entrydate" timestamp, "fileextension" varchar(255),
>>>> "content" varchar(1048576) for bit data, "case_documents_e_id"
>>>> bigint, "case_documents_idx" integer, econtainer_class varchar(255),
>>>> e_container varchar(255), e_container_featureid integer, primary key
>>>> (e_id))
>>>>
>>>> Martin Taal wrote:
>>>>
>>>>> Hi Alexandros,
>>>>> You can set an @Lob annotation in ecore also. See a post on this a
>>>>> few days back with the title: [Teneo] Text mapping instead of VarChar
>>>>> (although this post talks about the text sql type it also applies
>>>>> to your binary blob case).
>>>>>
>>>>> gr. Martin
>>>>>
>>>>>
>>>>> Alexandros Karypidis wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I'm trying to persist binary objects using Teneo. What's the
>>>>>> suggested method of doing that? I tried using the EByteArray data
>>>>>> type, as it was the closest one to a BLOB I could find. Here's an
>>>>>> example model:
>>>>>>
>>>>>> <eClassifiers xsi:type="ecore:EClass" name="Document">
>>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>>>>>> name="filename" eType="ecore:EDataType
>>>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>>>>>> name="content" eType="ecore:EDataType
>>>>>> http://www.eclipse.org/emf/2002/Ecore#//EByteArray"/>
>>>>>> </eClassifiers>
>>>>>>
>>>>>> Teneo creates a table "document_content" and creates a row each
>>>>>> byte in the array.
>>>>>>
>>>>>> The only relevant documentation I found was:
>>>>>> http://www.elver.org/hibernate/ejb3_features.html#lob_notes
>>>>>> My model is not written as an XML schema. How does this map to a
>>>>>> .ecore specification?
>>>>>>
>>>>>> P.S. I use hibernate 3.2.5 and Derby as the database backend.
>>>>>
>>>>>
>>>
>>>
>
>
|
|
|
Re: Large objects (BLOB) [message #612654 is a reply to message #103593] |
Thu, 22 November 2007 12:49 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Thanks for the summary I will add it to the docs in the next build.
gr. Martin
Alexandros Karypidis wrote:
> Yep, works like a charm! :-)
>
> P.S. If you've been searching the archives, the summary is:
>
> 1) Add an EDataType for java.sql.Blob in your ecore:
>
> <eClassifiers xsi:type="ecore:EDataType" name="Blob"
> instanceClassName="java.sql.Blob"/>
>
> 2) In the attribute of type Blob, add "teneo.jpa" annotations as follows
> in your ecore:
>
> ....
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="content"
> eType="#//Blob">
> <eAnnotations source="teneo.jpa">
> <details key="value"
> value=" @Lob
@Column(length=1048576)
&# xA;@Type(type="blob") "/>
>
> </eAnnotations>
> </eStructuralFeatures>
> ....
>
> Notice the 1MB column length if you copy-paste. Change it to what you need.
>
> 3) Use the blob as you would with hibernate. For instance:
>
> Document doc = SolonFactory.eINSTANCE.createDocument();
> Blob blob = Hibernate.createBlob(new byte[] { 1, 2, 3, 4 });
> doc.setContent(blob);
>
> Martin Taal wrote:
>
>> You can try the following annotation to set the type to blob:
>> @Type(type="blob")
>> the other two annotations (lob and column) should remain there.
>> Btw, you can enter multiple annotation in one eannotation (the value
>> of the details is opened in a multi-line editor).
>>
>> gr. Martin
>>
>> Alexandros Karypidis wrote:
>>> This is it:
>>>
>>> --------------------------------------------------------
>>> ....
>>> <property name="content" lazy="false" insert="true" update="true"
>>> not-null="false" unique="false" type="binary">
>>> <column not-null="false" unique="false" name="`content`"
>>> length="1048576"/>
>>> </property>
>>> </class>
>>> --------------------------------------------------------
>>>
>>> type="binary" and length="1048576"
>>>
>>> I believe hibernate accepts type="blob" and type="clob", which would
>>> probably do what I'd like.
>>>
>>> Martin Taal wrote:
>>>
>>>> How does the hbm mapping look like for the content feature? You can
>>>> see the mapping by doing getMappingXML on the datastore, you can
>>>> call this method also when the initialize fails.
>>>>
>>>> gr. Martin
>>>>
>>>> Alexandros Karypidis wrote:
>>>>> Ok, I added:
>>>>>
>>>>> <eAnnotations source="teneo.jpa">
>>>>> <details key="value" value="@Lob"/>
>>>>> </eAnnotations>
>>>>> <eAnnotations source="teneo.jpa">
>>>>> <details key="value" value="@Column(length=1048576)"/>
>>>>> </eAnnotations>
>>>>>
>>>>> Now the database schema creation fails because hibernate tries to
>>>>> create a column of type "VARCHAR FOR BITDATA" whose maximum length
>>>>> is 32768 bytes. Derby has CLOB / BLOB fields. Does Teneo have any
>>>>> control over this or is it a hibernate issue?
>>>>>
>>>>> P.S. the runtime log fails to create table "document" as follows:
>>>>>
>>>>> 2140 [main] DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate - create
>>>>> table "document" (e_id bigint not null, "dtype" varchar(255) not
>>>>> null, e_version integer not null, "description" varchar(255),
>>>>> "entrydate" timestamp, "fileextension" varchar(255), "content"
>>>>> varchar(1048576) for bit data, "case_documents_e_id" bigint,
>>>>> "case_documents_idx" integer, econtainer_class varchar(255),
>>>>> e_container varchar(255), e_container_featureid integer, primary
>>>>> key (e_id))
>>>>>
>>>>> 2156 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate -
>>>>> Unsuccessful: create table "document" (e_id bigint not null,
>>>>> "dtype" varchar(255) not null, e_version integer not null,
>>>>> "description" varchar(255), "entrydate" timestamp, "fileextension"
>>>>> varchar(255), "content" varchar(1048576) for bit data,
>>>>> "case_documents_e_id" bigint, "case_documents_idx" integer,
>>>>> econtainer_class varchar(255), e_container varchar(255),
>>>>> e_container_featureid integer, primary key (e_id))
>>>>>
>>>>> Martin Taal wrote:
>>>>>
>>>>>> Hi Alexandros,
>>>>>> You can set an @Lob annotation in ecore also. See a post on this a
>>>>>> few days back with the title: [Teneo] Text mapping instead of VarChar
>>>>>> (although this post talks about the text sql type it also applies
>>>>>> to your binary blob case).
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>>
>>>>>> Alexandros Karypidis wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> I'm trying to persist binary objects using Teneo. What's the
>>>>>>> suggested method of doing that? I tried using the EByteArray data
>>>>>>> type, as it was the closest one to a BLOB I could find. Here's an
>>>>>>> example model:
>>>>>>>
>>>>>>> <eClassifiers xsi:type="ecore:EClass" name="Document">
>>>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>>>>>>> name="filename" eType="ecore:EDataType
>>>>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>>>>>>> name="content" eType="ecore:EDataType
>>>>>>> http://www.eclipse.org/emf/2002/Ecore#//EByteArray"/>
>>>>>>> </eClassifiers>
>>>>>>>
>>>>>>> Teneo creates a table "document_content" and creates a row each
>>>>>>> byte in the array.
>>>>>>>
>>>>>>> The only relevant documentation I found was:
>>>>>>> http://www.elver.org/hibernate/ejb3_features.html#lob_notes
>>>>>>> My model is not written as an XML schema. How does this map to a
>>>>>>> .ecore specification?
>>>>>>>
>>>>>>> P.S. I use hibernate 3.2.5 and Derby as the database backend.
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Goto Forum:
Current Time: Sat Nov 09 02:26:00 GMT 2024
Powered by FUDForum. Page generated in 0.04235 seconds
|