Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Identifier for my objects
[Teneo] Identifier for my objects [message #86983] Thu, 21 June 2007 09:43 Go to next message
Eclipse UserFriend
Originally posted by: gonzalinlinWITHOUT_THIS.tiscali.es

Hi Martin!

I've designed my model using EMF, and then generated my hibernate.hbm.xml
mapping file using Teneo. This is for a web application.
Here is an excerpt:

<!-- Generated by Teneo on Mon May 07 19:41:00 CEST 2007 -->
<hibernate-mapping>

<class entity-name="Factura" abstract="false" lazy="false"
discriminator-value="Factura" table="`factura`">

<meta attribute="eclassName">Factura</meta>

<meta attribute="epackage">http://productoexpediente.factura</meta>

<id type="long" name="e_id" column="e_id"
access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">

So Teneo creates an id called "e_id", but I haven't any id in my classes.

My question is: Must all my objects extend a class (for example:
"AbstractObject") with an attribute "id"?

If I execute the method findAll() in the DAO, How can I retrieve the
attributes of a particular instance returned by findAll()? I suppose I need
the id of that instance, so how can I get that id to retrieve the other
attributes?

Thank you again!

With regards,

Gonzalo
Re: [Teneo] Identifier for my objects [message #86998 is a reply to message #86983] Thu, 21 June 2007 10:08 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Gonzalo,
The synthetic id is automatically added by Teneo to every type which does not have an explicit id
property (i.e. annotated with the @id property). In general it is better/easier to have an explicit
id property.
You can add an id efeature to each eclass to solve this.
Or as you suggest you can create an (abstract) super type which has an id feature. All types will
then inherit from this abstract superclass. As a default Teneo will create a table for this abstract
super class also. If you don't want that then you need to set the @MappedSuperclass annotation in
the abstract supertype.

If you choose to add an id efeature to each type then it can be an idea to define a separate
edatatype for the id. The @id annotation can then be set in this edatatype. Probably the id is an
auto-increment long (or something similar), in this case you should also add the @GeneratedValue
annotation to the id edatatype/efeature.

Note that the above also applies to the version concept. It is better in general to have an explicit
version efeature also in your model. Although it is not to nice to have such an explicit 'low-level'
concept in the business model it is required when you (de-)serialize your objects.

gr. Martin

Gonzalo wrote:
> Hi Martin!
>
> I've designed my model using EMF, and then generated my hibernate.hbm.xml
> mapping file using Teneo. This is for a web application.
> Here is an excerpt:
>
> <!-- Generated by Teneo on Mon May 07 19:41:00 CEST 2007 -->
> <hibernate-mapping>
>
> <class entity-name="Factura" abstract="false" lazy="false"
> discriminator-value="Factura" table="`factura`">
>
> <meta attribute="eclassName">Factura</meta>
>
> <meta attribute="epackage">http://productoexpediente.factura</meta>
>
> <id type="long" name="e_id" column="e_id"
> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>
> So Teneo creates an id called "e_id", but I haven't any id in my classes.
>
> My question is: Must all my objects extend a class (for example:
> "AbstractObject") with an attribute "id"?
>
> If I execute the method findAll() in the DAO, How can I retrieve the
> attributes of a particular instance returned by findAll()? I suppose I need
> the id of that instance, so how can I get that id to retrieve the other
> attributes?
>
> Thank you again!
>
> With regards,
>
> Gonzalo
>
>


--

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: [Teneo] Identifier for my objects [message #87012 is a reply to message #86998] Thu, 21 June 2007 10:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: gonzalinlinWITHOUT_THIS.tiscali.es

Thank you very much, Martin! :)
With regards,
Gonzalo
"Martin Taal" <mtaal@elver.org> escribi
Re: [Teneo] Identifier for my objects [message #88268 is a reply to message #86998] Thu, 05 July 2007 14:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: FIRSTNAME.LASTNAME.sphere.ae

Hi,

We tried that, but got ...

org.hibernate.id.IdentifierGenerationException: this id generator
generates long, integer, short

.... when saving something.

Our annotation.xml looks like this

[...]
<edatatype name="IdentifierType">
<generated-value />
<id />
</edatatype>
[...]

the generated mapping XML:

[...]
<id name="id" type="to.IdentifierType">
<column not-null="true" unique="true" name="`id`"/>
<generator class="native"/>
</id>
[...]

Hibernate expect to see "long" in the type-attribute... but we're ran
out of ideas how to get from our EDataType to long...

Thanks in advance,

Tom.




Martin Taal wrote:
> Hi Gonzalo,
> The synthetic id is automatically added by Teneo to every type which
> does not have an explicit id property (i.e. annotated with the @id
> property). In general it is better/easier to have an explicit id property.
> You can add an id efeature to each eclass to solve this.
> Or as you suggest you can create an (abstract) super type which has an
> id feature. All types will then inherit from this abstract superclass.
> As a default Teneo will create a table for this abstract super class
> also. If you don't want that then you need to set the @MappedSuperclass
> annotation in the abstract supertype.
>
> If you choose to add an id efeature to each type then it can be an idea
> to define a separate edatatype for the id. The @id annotation can then
> be set in this edatatype. Probably the id is an auto-increment long (or
> something similar), in this case you should also add the @GeneratedValue
> annotation to the id edatatype/efeature.
>
> Note that the above also applies to the version concept. It is better in
> general to have an explicit version efeature also in your model.
> Although it is not to nice to have such an explicit 'low-level' concept
> in the business model it is required when you (de-)serialize your objects.
>
> gr. Martin
>
> Gonzalo wrote:
>> Hi Martin!
>>
>> I've designed my model using EMF, and then generated my
>> hibernate.hbm.xml mapping file using Teneo. This is for a web
>> application.
>> Here is an excerpt:
>>
>> <!-- Generated by Teneo on Mon May 07 19:41:00 CEST 2007 -->
>> <hibernate-mapping>
>>
>> <class entity-name="Factura" abstract="false" lazy="false"
>> discriminator-value="Factura" table="`factura`">
>>
>> <meta attribute="eclassName">Factura</meta>
>>
>> <meta attribute="epackage">http://productoexpediente.factura</meta>
>>
>> <id type="long" name="e_id" column="e_id"
>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>
>>
>> So Teneo creates an id called "e_id", but I haven't any id in my classes.
>>
>> My question is: Must all my objects extend a class (for example:
>> "AbstractObject") with an attribute "id"?
>>
>> If I execute the method findAll() in the DAO, How can I retrieve the
>> attributes of a particular instance returned by findAll()? I suppose I
>> need the id of that instance, so how can I get that id to retrieve the
>> other attributes?
>>
>> Thank you again!
>>
>> With regards,
>>
>> Gonzalo
>>
>>
>
>
Re: [Teneo] Identifier for my objects [message #88298 is a reply to message #88268] Thu, 05 July 2007 16:58 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
How does the ecore for this eDataType look like?
Does it have an instance class name set? You can try java.lang.Long or long.

gr. Martin

Thomas Kuhn wrote:
> Hi,
>
> We tried that, but got ...
>
> org.hibernate.id.IdentifierGenerationException: this id generator
> generates long, integer, short
>
> .... when saving something.
>
> Our annotation.xml looks like this
>
> [...]
> <edatatype name="IdentifierType">
> <generated-value />
> <id />
> </edatatype>
> [...]
>
> the generated mapping XML:
>
> [...]
> <id name="id" type="to.IdentifierType">
> <column not-null="true" unique="true" name="`id`"/>
> <generator class="native"/>
> </id>
> [...]
>
> Hibernate expect to see "long" in the type-attribute... but we're ran
> out of ideas how to get from our EDataType to long...
>
> Thanks in advance,
>
> Tom.
>
>
>
>
> Martin Taal wrote:
>> Hi Gonzalo,
>> The synthetic id is automatically added by Teneo to every type which
>> does not have an explicit id property (i.e. annotated with the @id
>> property). In general it is better/easier to have an explicit id
>> property.
>> You can add an id efeature to each eclass to solve this.
>> Or as you suggest you can create an (abstract) super type which has an
>> id feature. All types will then inherit from this abstract superclass.
>> As a default Teneo will create a table for this abstract super class
>> also. If you don't want that then you need to set the
>> @MappedSuperclass annotation in the abstract supertype.
>>
>> If you choose to add an id efeature to each type then it can be an
>> idea to define a separate edatatype for the id. The @id annotation can
>> then be set in this edatatype. Probably the id is an auto-increment
>> long (or something similar), in this case you should also add the
>> @GeneratedValue annotation to the id edatatype/efeature.
>>
>> Note that the above also applies to the version concept. It is better
>> in general to have an explicit version efeature also in your model.
>> Although it is not to nice to have such an explicit 'low-level'
>> concept in the business model it is required when you (de-)serialize
>> your objects.
>>
>> gr. Martin
>>
>> Gonzalo wrote:
>>> Hi Martin!
>>>
>>> I've designed my model using EMF, and then generated my
>>> hibernate.hbm.xml mapping file using Teneo. This is for a web
>>> application.
>>> Here is an excerpt:
>>>
>>> <!-- Generated by Teneo on Mon May 07 19:41:00 CEST 2007 -->
>>> <hibernate-mapping>
>>>
>>> <class entity-name="Factura" abstract="false" lazy="false"
>>> discriminator-value="Factura" table="`factura`">
>>>
>>> <meta attribute="eclassName">Factura</meta>
>>>
>>> <meta attribute="epackage">http://productoexpediente.factura</meta>
>>>
>>> <id type="long" name="e_id" column="e_id"
>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>
>>>
>>> So Teneo creates an id called "e_id", but I haven't any id in my
>>> classes.
>>>
>>> My question is: Must all my objects extend a class (for example:
>>> "AbstractObject") with an attribute "id"?
>>>
>>> If I execute the method findAll() in the DAO, How can I retrieve the
>>> attributes of a particular instance returned by findAll()? I suppose
>>> I need the id of that instance, so how can I get that id to retrieve
>>> the other attributes?
>>>
>>> Thank you again!
>>>
>>> With regards,
>>>
>>> Gonzalo
>>>
>>>
>>
>>


--

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: [Teneo] Identifier for my objects [message #88314 is a reply to message #88298] Thu, 05 July 2007 16:59 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
I forgot to mention that after changing the ecore you have to re-generate your java code to get the
ecore change into the runtime ecore model.

gr. Martin

Martin Taal wrote:
> How does the ecore for this eDataType look like?
> Does it have an instance class name set? You can try java.lang.Long or
> long.
>
> gr. Martin
>
> Thomas Kuhn wrote:
>> Hi,
>>
>> We tried that, but got ...
>>
>> org.hibernate.id.IdentifierGenerationException: this id generator
>> generates long, integer, short
>>
>> .... when saving something.
>>
>> Our annotation.xml looks like this
>>
>> [...]
>> <edatatype name="IdentifierType">
>> <generated-value />
>> <id />
>> </edatatype>
>> [...]
>>
>> the generated mapping XML:
>>
>> [...]
>> <id name="id" type="to.IdentifierType">
>> <column not-null="true" unique="true" name="`id`"/>
>> <generator class="native"/>
>> </id>
>> [...]
>>
>> Hibernate expect to see "long" in the type-attribute... but we're ran
>> out of ideas how to get from our EDataType to long...
>>
>> Thanks in advance,
>>
>> Tom.
>>
>>
>>
>>
>> Martin Taal wrote:
>>> Hi Gonzalo,
>>> The synthetic id is automatically added by Teneo to every type which
>>> does not have an explicit id property (i.e. annotated with the @id
>>> property). In general it is better/easier to have an explicit id
>>> property.
>>> You can add an id efeature to each eclass to solve this.
>>> Or as you suggest you can create an (abstract) super type which has
>>> an id feature. All types will then inherit from this abstract
>>> superclass. As a default Teneo will create a table for this abstract
>>> super class also. If you don't want that then you need to set the
>>> @MappedSuperclass annotation in the abstract supertype.
>>>
>>> If you choose to add an id efeature to each type then it can be an
>>> idea to define a separate edatatype for the id. The @id annotation
>>> can then be set in this edatatype. Probably the id is an
>>> auto-increment long (or something similar), in this case you should
>>> also add the @GeneratedValue annotation to the id edatatype/efeature.
>>>
>>> Note that the above also applies to the version concept. It is better
>>> in general to have an explicit version efeature also in your model.
>>> Although it is not to nice to have such an explicit 'low-level'
>>> concept in the business model it is required when you (de-)serialize
>>> your objects.
>>>
>>> gr. Martin
>>>
>>> Gonzalo wrote:
>>>> Hi Martin!
>>>>
>>>> I've designed my model using EMF, and then generated my
>>>> hibernate.hbm.xml mapping file using Teneo. This is for a web
>>>> application.
>>>> Here is an excerpt:
>>>>
>>>> <!-- Generated by Teneo on Mon May 07 19:41:00 CEST 2007 -->
>>>> <hibernate-mapping>
>>>>
>>>> <class entity-name="Factura" abstract="false" lazy="false"
>>>> discriminator-value="Factura" table="`factura`">
>>>>
>>>> <meta attribute="eclassName">Factura</meta>
>>>>
>>>> <meta attribute="epackage">http://productoexpediente.factura</meta>
>>>>
>>>> <id type="long" name="e_id" column="e_id"
>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>>
>>>>
>>>> So Teneo creates an id called "e_id", but I haven't any id in my
>>>> classes.
>>>>
>>>> My question is: Must all my objects extend a class (for example:
>>>> "AbstractObject") with an attribute "id"?
>>>>
>>>> If I execute the method findAll() in the DAO, How can I retrieve the
>>>> attributes of a particular instance returned by findAll()? I suppose
>>>> I need the id of that instance, so how can I get that id to retrieve
>>>> the other attributes?
>>>>
>>>> Thank you again!
>>>>
>>>> With regards,
>>>>
>>>> Gonzalo
>>>>
>>>>
>>>
>>>
>
>


--

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: [Teneo] Identifier for my objects [message #88508 is a reply to message #88314] Fri, 06 July 2007 17:27 Go to previous message
Eclipse UserFriend
Originally posted by: FIRSTNAME.LASTNAME.sphere.ae

I changed the instance class name to Long, now it works.

Thanks a lot!

Tom

Martin Taal wrote:
> I forgot to mention that after changing the ecore you have to
> re-generate your java code to get the ecore change into the runtime
> ecore model.
>
> gr. Martin
>
> Martin Taal wrote:
>> How does the ecore for this eDataType look like?
>> Does it have an instance class name set? You can try java.lang.Long or
>> long.
>>
>> gr. Martin
Re: [Teneo] Identifier for my objects [message #607031 is a reply to message #86983] Thu, 21 June 2007 10:08 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Gonzalo,
The synthetic id is automatically added by Teneo to every type which does not have an explicit id
property (i.e. annotated with the @id property). In general it is better/easier to have an explicit
id property.
You can add an id efeature to each eclass to solve this.
Or as you suggest you can create an (abstract) super type which has an id feature. All types will
then inherit from this abstract superclass. As a default Teneo will create a table for this abstract
super class also. If you don't want that then you need to set the @MappedSuperclass annotation in
the abstract supertype.

If you choose to add an id efeature to each type then it can be an idea to define a separate
edatatype for the id. The @id annotation can then be set in this edatatype. Probably the id is an
auto-increment long (or something similar), in this case you should also add the @GeneratedValue
annotation to the id edatatype/efeature.

Note that the above also applies to the version concept. It is better in general to have an explicit
version efeature also in your model. Although it is not to nice to have such an explicit 'low-level'
concept in the business model it is required when you (de-)serialize your objects.

gr. Martin

Gonzalo wrote:
> Hi Martin!
>
> I've designed my model using EMF, and then generated my hibernate.hbm.xml
> mapping file using Teneo. This is for a web application.
> Here is an excerpt:
>
> <!-- Generated by Teneo on Mon May 07 19:41:00 CEST 2007 -->
> <hibernate-mapping>
>
> <class entity-name="Factura" abstract="false" lazy="false"
> discriminator-value="Factura" table="`factura`">
>
> <meta attribute="eclassName">Factura</meta>
>
> <meta attribute="epackage">http://productoexpediente.factura</meta>
>
> <id type="long" name="e_id" column="e_id"
> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>
> So Teneo creates an id called "e_id", but I haven't any id in my classes.
>
> My question is: Must all my objects extend a class (for example:
> "AbstractObject") with an attribute "id"?
>
> If I execute the method findAll() in the DAO, How can I retrieve the
> attributes of a particular instance returned by findAll()? I suppose I need
> the id of that instance, so how can I get that id to retrieve the other
> attributes?
>
> Thank you again!
>
> With regards,
>
> Gonzalo
>
>


--

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: [Teneo] Identifier for my objects [message #607032 is a reply to message #86998] Thu, 21 June 2007 10:54 Go to previous message
Gonzalo is currently offline GonzaloFriend
Messages: 27
Registered: July 2009
Junior Member
Thank you very much, Martin! :)
With regards,
Gonzalo
"Martin Taal" <mtaal@elver.org> escribi
Re: [Teneo] Identifier for my objects [message #608649 is a reply to message #86998] Thu, 05 July 2007 14:18 Go to previous message
Thomas Kuhn is currently offline Thomas KuhnFriend
Messages: 9
Registered: July 2009
Junior Member
Hi,

We tried that, but got ...

org.hibernate.id.IdentifierGenerationException: this id generator
generates long, integer, short

.... when saving something.

Our annotation.xml looks like this

[...]
<edatatype name="IdentifierType">
<generated-value />
<id />
</edatatype>
[...]

the generated mapping XML:

[...]
<id name="id" type="to.IdentifierType">
<column not-null="true" unique="true" name="`id`"/>
<generator class="native"/>
</id>
[...]

Hibernate expect to see "long" in the type-attribute... but we're ran
out of ideas how to get from our EDataType to long...

Thanks in advance,

Tom.




Martin Taal wrote:
> Hi Gonzalo,
> The synthetic id is automatically added by Teneo to every type which
> does not have an explicit id property (i.e. annotated with the @id
> property). In general it is better/easier to have an explicit id property.
> You can add an id efeature to each eclass to solve this.
> Or as you suggest you can create an (abstract) super type which has an
> id feature. All types will then inherit from this abstract superclass.
> As a default Teneo will create a table for this abstract super class
> also. If you don't want that then you need to set the @MappedSuperclass
> annotation in the abstract supertype.
>
> If you choose to add an id efeature to each type then it can be an idea
> to define a separate edatatype for the id. The @id annotation can then
> be set in this edatatype. Probably the id is an auto-increment long (or
> something similar), in this case you should also add the @GeneratedValue
> annotation to the id edatatype/efeature.
>
> Note that the above also applies to the version concept. It is better in
> general to have an explicit version efeature also in your model.
> Although it is not to nice to have such an explicit 'low-level' concept
> in the business model it is required when you (de-)serialize your objects.
>
> gr. Martin
>
> Gonzalo wrote:
>> Hi Martin!
>>
>> I've designed my model using EMF, and then generated my
>> hibernate.hbm.xml mapping file using Teneo. This is for a web
>> application.
>> Here is an excerpt:
>>
>> <!-- Generated by Teneo on Mon May 07 19:41:00 CEST 2007 -->
>> <hibernate-mapping>
>>
>> <class entity-name="Factura" abstract="false" lazy="false"
>> discriminator-value="Factura" table="`factura`">
>>
>> <meta attribute="eclassName">Factura</meta>
>>
>> <meta attribute="epackage">http://productoexpediente.factura</meta>
>>
>> <id type="long" name="e_id" column="e_id"
>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>
>>
>> So Teneo creates an id called "e_id", but I haven't any id in my classes.
>>
>> My question is: Must all my objects extend a class (for example:
>> "AbstractObject") with an attribute "id"?
>>
>> If I execute the method findAll() in the DAO, How can I retrieve the
>> attributes of a particular instance returned by findAll()? I suppose I
>> need the id of that instance, so how can I get that id to retrieve the
>> other attributes?
>>
>> Thank you again!
>>
>> With regards,
>>
>> Gonzalo
>>
>>
>
>
Re: [Teneo] Identifier for my objects [message #608651 is a reply to message #88268] Thu, 05 July 2007 16:58 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
How does the ecore for this eDataType look like?
Does it have an instance class name set? You can try java.lang.Long or long.

gr. Martin

Thomas Kuhn wrote:
> Hi,
>
> We tried that, but got ...
>
> org.hibernate.id.IdentifierGenerationException: this id generator
> generates long, integer, short
>
> .... when saving something.
>
> Our annotation.xml looks like this
>
> [...]
> <edatatype name="IdentifierType">
> <generated-value />
> <id />
> </edatatype>
> [...]
>
> the generated mapping XML:
>
> [...]
> <id name="id" type="to.IdentifierType">
> <column not-null="true" unique="true" name="`id`"/>
> <generator class="native"/>
> </id>
> [...]
>
> Hibernate expect to see "long" in the type-attribute... but we're ran
> out of ideas how to get from our EDataType to long...
>
> Thanks in advance,
>
> Tom.
>
>
>
>
> Martin Taal wrote:
>> Hi Gonzalo,
>> The synthetic id is automatically added by Teneo to every type which
>> does not have an explicit id property (i.e. annotated with the @id
>> property). In general it is better/easier to have an explicit id
>> property.
>> You can add an id efeature to each eclass to solve this.
>> Or as you suggest you can create an (abstract) super type which has an
>> id feature. All types will then inherit from this abstract superclass.
>> As a default Teneo will create a table for this abstract super class
>> also. If you don't want that then you need to set the
>> @MappedSuperclass annotation in the abstract supertype.
>>
>> If you choose to add an id efeature to each type then it can be an
>> idea to define a separate edatatype for the id. The @id annotation can
>> then be set in this edatatype. Probably the id is an auto-increment
>> long (or something similar), in this case you should also add the
>> @GeneratedValue annotation to the id edatatype/efeature.
>>
>> Note that the above also applies to the version concept. It is better
>> in general to have an explicit version efeature also in your model.
>> Although it is not to nice to have such an explicit 'low-level'
>> concept in the business model it is required when you (de-)serialize
>> your objects.
>>
>> gr. Martin
>>
>> Gonzalo wrote:
>>> Hi Martin!
>>>
>>> I've designed my model using EMF, and then generated my
>>> hibernate.hbm.xml mapping file using Teneo. This is for a web
>>> application.
>>> Here is an excerpt:
>>>
>>> <!-- Generated by Teneo on Mon May 07 19:41:00 CEST 2007 -->
>>> <hibernate-mapping>
>>>
>>> <class entity-name="Factura" abstract="false" lazy="false"
>>> discriminator-value="Factura" table="`factura`">
>>>
>>> <meta attribute="eclassName">Factura</meta>
>>>
>>> <meta attribute="epackage">http://productoexpediente.factura</meta>
>>>
>>> <id type="long" name="e_id" column="e_id"
>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>
>>>
>>> So Teneo creates an id called "e_id", but I haven't any id in my
>>> classes.
>>>
>>> My question is: Must all my objects extend a class (for example:
>>> "AbstractObject") with an attribute "id"?
>>>
>>> If I execute the method findAll() in the DAO, How can I retrieve the
>>> attributes of a particular instance returned by findAll()? I suppose
>>> I need the id of that instance, so how can I get that id to retrieve
>>> the other attributes?
>>>
>>> Thank you again!
>>>
>>> With regards,
>>>
>>> Gonzalo
>>>
>>>
>>
>>


--

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: [Teneo] Identifier for my objects [message #608652 is a reply to message #88298] Thu, 05 July 2007 16:59 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
I forgot to mention that after changing the ecore you have to re-generate your java code to get the
ecore change into the runtime ecore model.

gr. Martin

Martin Taal wrote:
> How does the ecore for this eDataType look like?
> Does it have an instance class name set? You can try java.lang.Long or
> long.
>
> gr. Martin
>
> Thomas Kuhn wrote:
>> Hi,
>>
>> We tried that, but got ...
>>
>> org.hibernate.id.IdentifierGenerationException: this id generator
>> generates long, integer, short
>>
>> .... when saving something.
>>
>> Our annotation.xml looks like this
>>
>> [...]
>> <edatatype name="IdentifierType">
>> <generated-value />
>> <id />
>> </edatatype>
>> [...]
>>
>> the generated mapping XML:
>>
>> [...]
>> <id name="id" type="to.IdentifierType">
>> <column not-null="true" unique="true" name="`id`"/>
>> <generator class="native"/>
>> </id>
>> [...]
>>
>> Hibernate expect to see "long" in the type-attribute... but we're ran
>> out of ideas how to get from our EDataType to long...
>>
>> Thanks in advance,
>>
>> Tom.
>>
>>
>>
>>
>> Martin Taal wrote:
>>> Hi Gonzalo,
>>> The synthetic id is automatically added by Teneo to every type which
>>> does not have an explicit id property (i.e. annotated with the @id
>>> property). In general it is better/easier to have an explicit id
>>> property.
>>> You can add an id efeature to each eclass to solve this.
>>> Or as you suggest you can create an (abstract) super type which has
>>> an id feature. All types will then inherit from this abstract
>>> superclass. As a default Teneo will create a table for this abstract
>>> super class also. If you don't want that then you need to set the
>>> @MappedSuperclass annotation in the abstract supertype.
>>>
>>> If you choose to add an id efeature to each type then it can be an
>>> idea to define a separate edatatype for the id. The @id annotation
>>> can then be set in this edatatype. Probably the id is an
>>> auto-increment long (or something similar), in this case you should
>>> also add the @GeneratedValue annotation to the id edatatype/efeature.
>>>
>>> Note that the above also applies to the version concept. It is better
>>> in general to have an explicit version efeature also in your model.
>>> Although it is not to nice to have such an explicit 'low-level'
>>> concept in the business model it is required when you (de-)serialize
>>> your objects.
>>>
>>> gr. Martin
>>>
>>> Gonzalo wrote:
>>>> Hi Martin!
>>>>
>>>> I've designed my model using EMF, and then generated my
>>>> hibernate.hbm.xml mapping file using Teneo. This is for a web
>>>> application.
>>>> Here is an excerpt:
>>>>
>>>> <!-- Generated by Teneo on Mon May 07 19:41:00 CEST 2007 -->
>>>> <hibernate-mapping>
>>>>
>>>> <class entity-name="Factura" abstract="false" lazy="false"
>>>> discriminator-value="Factura" table="`factura`">
>>>>
>>>> <meta attribute="eclassName">Factura</meta>
>>>>
>>>> <meta attribute="epackage">http://productoexpediente.factura</meta>
>>>>
>>>> <id type="long" name="e_id" column="e_id"
>>>> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
>>>>
>>>>
>>>> So Teneo creates an id called "e_id", but I haven't any id in my
>>>> classes.
>>>>
>>>> My question is: Must all my objects extend a class (for example:
>>>> "AbstractObject") with an attribute "id"?
>>>>
>>>> If I execute the method findAll() in the DAO, How can I retrieve the
>>>> attributes of a particular instance returned by findAll()? I suppose
>>>> I need the id of that instance, so how can I get that id to retrieve
>>>> the other attributes?
>>>>
>>>> Thank you again!
>>>>
>>>> With regards,
>>>>
>>>> Gonzalo
>>>>
>>>>
>>>
>>>
>
>


--

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: [Teneo] Identifier for my objects [message #608665 is a reply to message #88314] Fri, 06 July 2007 17:27 Go to previous message
Thomas Kuhn is currently offline Thomas KuhnFriend
Messages: 9
Registered: July 2009
Junior Member
I changed the instance class name to Long, now it works.

Thanks a lot!

Tom

Martin Taal wrote:
> I forgot to mention that after changing the ecore you have to
> re-generate your java code to get the ecore change into the runtime
> ecore model.
>
> gr. Martin
>
> Martin Taal wrote:
>> How does the ecore for this eDataType look like?
>> Does it have an instance class name set? You can try java.lang.Long or
>> long.
>>
>> gr. Martin
Previous Topic:Import XMI
Next Topic:Can Teneo start from the database schema as a model?
Goto Forum:
  


Current Time: Tue Apr 16 18:09:11 GMT 2024

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

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

Back to the top