Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Large objects (BLOB)
Large objects (BLOB) [message #103414] Wed, 21 November 2007 10:32 Go to next message
Eclipse UserFriend
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 #103430 is a reply to message #103414] Wed, 21 November 2007 10:39 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
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 #103473 is a reply to message #103430] Wed, 21 November 2007 16:34 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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&#xD;&#xA;@Column(length=1048576)&#xD;&# xA;@Type(type=&quot;blob&quot;) "/>
</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 Go to previous message
Martin Taal is currently offline Martin TaalFriend
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&#xD;&#xA;@Column(length=1048576)&#xD;&# xA;@Type(type=&quot;blob&quot;) "/>
>
> </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 #612632 is a reply to message #103414] Wed, 21 November 2007 10:39 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
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 Go to previous message
Alex Mising name is currently offline Alex Mising nameFriend
Messages: 135
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 Go to previous message
Martin Taal is currently offline Martin TaalFriend
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 Go to previous message
Alex Mising name is currently offline Alex Mising nameFriend
Messages: 135
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 Go to previous message
Martin Taal is currently offline Martin TaalFriend
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 Go to previous message
Alex Mising name is currently offline Alex Mising nameFriend
Messages: 135
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&#xD;&#xA;@Column(length=1048576)&#xD;&# xA;@Type(type=&quot;blob&quot;) "/>
</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 Go to previous message
Martin Taal is currently offline Martin TaalFriend
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&#xD;&#xA;@Column(length=1048576)&#xD;&# xA;@Type(type=&quot;blob&quot;) "/>
>
> </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
Previous Topic:[Teneo] Build update
Next Topic:[CDO 0.8.0] StoreAccessor could return less or more element than the reference Chunk ask for.
Goto Forum:
  


Current Time: Sat Oct 24 18:17:07 GMT 2020

Powered by FUDForum. Page generated in 0.02769 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top