Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Need help regarded emf generated model
Need help regarded emf generated model [message #421276] Sat, 02 August 2008 15:31 Go to next message
Eclipse UserFriend
Originally posted by: kalkar.prashant.gmail.com

Hi,

I am working on an project which use xsd schema, and generate the model
code with emf, teneo and hibernate plugins.

The generated code allows to access the fields in the db tables. But no
methods are generated to access the primary key (e_id column) of the table.

Since ability to assess primary key to identify unique record in table
is basic, that should be present in the generated code.

Am I missing any basic concept here? Is there any other way to access
the primary key.

Please help.

Regards,
Prashant
Re: Need help regarded emf generated model [message #421278 is a reply to message #421276] Sat, 02 August 2008 15:57 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Prashant,

I suppose this is more of a Teneo question since EMF itself will only
generate the model's client API based on what's in your schema. Using
Teneo doesn't change the generated model so if there are underlying data
base concepts you want to access directly, you'd need to drop down to
that level of abstraction. Perhaps x.eResource().getFragment(x) returns
what you want; I'm just guessing...


Prashant Kalkar wrote:
> Hi,
>
> I am working on an project which use xsd schema, and generate the
> model code with emf, teneo and hibernate plugins.
>
> The generated code allows to access the fields in the db tables. But
> no methods are generated to access the primary key (e_id column) of
> the table.
>
> Since ability to assess primary key to identify unique record in table
> is basic, that should be present in the generated code.
>
> Am I missing any basic concept here? Is there any other way to access
> the primary key.
>
> Please help.
>
> Regards,
> Prashant


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Need help regarded emf generated model [message #421304 is a reply to message #421278] Sun, 03 August 2008 17:44 Go to previous messageGo to next message
Prashant is currently offline PrashantFriend
Messages: 6
Registered: July 2009
Junior Member
Hi,

Let me put the problem again.

The application model code is generated using EMF from XML schema, and
also teneo plugin is used for hibernate mapping.

The application creates the database for the first run, and each table
generated is assigned e_id as the primary key.

Since the e_id column (which is the table primary key) is generated, the
corresponding getter setter methods are not present for this column in the
module code.

All I want to know is there any way I can access the primary key using
EObject object for a given table.

Regards,
Prashant
Re: Need help regarded emf generated model [message #421306 is a reply to message #421304] Sun, 03 August 2008 17:51 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Prashant,

It's definitely a Teneo question. Hopefully Martin will notice it.


Prashant wrote:
> Hi,
>
> Let me put the problem again.
>
> The application model code is generated using EMF from XML schema, and
> also teneo plugin is used for hibernate mapping.
>
> The application creates the database for the first run, and each table
> generated is assigned e_id as the primary key.
>
> Since the e_id column (which is the table primary key) is generated,
> the corresponding getter setter methods are not present for this
> column in the module code.
> All I want to know is there any way I can access the primary key using
> EObject object for a given table.
>
> Regards,
> Prashant
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Need help regarded emf generated model [message #421307 is a reply to message #421306] Sun, 03 August 2008 18:17 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Prashant,
Teneo does not generate the java code for you. The implicit id's (and version) columns are added
automatically for convenience reasons for tutorials. For production applications I would not advice
to use it.
So you should explicitly define your id features/elements in the schema. An id feature should be
annotated with @Id (and @GeneratedValue if you want it to be set by the db). You can also define a
simple type in xsd and annotated the simpletype with @Id then you don't need to annotate each Id
feature.

The same applies to the version column.

Hope this helps.

gr. Martin

Ed Merks wrote:
> Prashant,
>
> It's definitely a Teneo question. Hopefully Martin will notice it.
>
>
> Prashant wrote:
>> Hi,
>>
>> Let me put the problem again.
>>
>> The application model code is generated using EMF from XML schema, and
>> also teneo plugin is used for hibernate mapping.
>>
>> The application creates the database for the first run, and each table
>> generated is assigned e_id as the primary key.
>>
>> Since the e_id column (which is the table primary key) is generated,
>> the corresponding getter setter methods are not present for this
>> column in the module code.
>> All I want to know is there any way I can access the primary key using
>> EObject object for a given table.
>>
>> Regards,
>> Prashant
>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
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: Need help regarded emf generated model [message #421308 is a reply to message #421307] Sun, 03 August 2008 18:40 Go to previous message
Prashant is currently offline PrashantFriend
Messages: 6
Registered: July 2009
Junior Member
Hi,

Thank you for your reply.

I found the way to access the id of the generated object.

I used the IdentifierCacheHandler.getID to retrieve the id information.

The information was present on the page:
http://www.elver.org/hibernate/hibernate_details.html , in the Synthetic
ID and Version properties section.

But I will follow your advice to define the Id columns explicitly.

Thanks again.

Regards,
Prashant
Previous Topic:Step towards more generic editor
Next Topic:Copy and Paste from one editor to another
Goto Forum:
  


Current Time: Thu Apr 25 21:04:41 GMT 2024

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

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

Back to the top