Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dali » resync Tables to Entities?
icon5.gif  resync Tables to Entities? [message #502667] Wed, 09 December 2009 10:58 Go to next message
Matty  is currently offline Matty Friend
Messages: 4
Registered: December 2009
Junior Member
Hi Folks,

iam totally new to Dali or Eclipse with JPA, and iam very excited about the possiblity to generate Entity-Classes from my existing DB-Schema.

Everything works fine. But i can't find out how to "resync" changes from my DB-Schema to the Java-Entity. Is there any hidden feature for this?

How do you handle it, if you changed something in the Entity Class (for example add @NamedQueryies ) and resync afterwards?

If i try to generate the Entities from Tables again then Eclipse asks to overwrite the Entity-Class, but i dont want to loose my changes.

Any ideas to this scenario? I believe iam not the only one who make manual changes.

Thanks in Advance for any hints and apologise my english, its not my mothers tongue.
Re: resync Tables to Entities? [message #502797 is a reply to message #502667] Wed, 09 December 2009 17:54 Go to previous messageGo to next message
Neil Hauge is currently offline Neil HaugeFriend
Messages: 475
Registered: July 2009
Senior Member
Hi,

In Dali, Entity Generation from Tables was developed as a starting point for your entities where you have an existing database schema. Entity Generation is not meant to generate a perfect model and should not take the place of developing a well designed object oriented model. That is to say that it is expected that further modification to these generated Entities will normally be required. As a result of these changes, which may be structural in nature, it would be difficult to sync database changes with the existing entities.

If the database schema is only undergoing small, incremental changes, than the best thing for you to do would be to simply edit your existing classes/entities by adding/changing the necessary fields and mapping them in the Java Editor or by using Dali's rich UI for configuring entities (Details View).

By using the UI, Dali will manage all of the annotations in the code, and will also provide you with their default values. In addition to this, when the database schema changes, Dali validation will indicate where existing mappings are no longer correct so you know where changes are necessary.

We don't yet validate queries, but this is something slated for the future.

In summary, Entity Generation should be used for prototyping and/or quick way to get started with your entities. If the database schema is in major flux, then it may be worth it to overwrite your existing entities (especially if you haven't modified them), but most of the time you will want to simply edit your existing entities as opposed to regenerate them.

Hope this helps,
Neil

Matty wrote on Wed, 09 December 2009 05:58
Hi Folks,

iam totally new to Dali or Eclipse with JPA, and iam very excited about the possiblity to generate Entity-Classes from my existing DB-Schema.

Everything works fine. But i can't find out how to "resync" changes from my DB-Schema to the Java-Entity. Is there any hidden feature for this?

How do you handle it, if you changed something in the Entity Class (for example add @NamedQueryies ) and resync afterwards?

If i try to generate the Entities from Tables again then Eclipse asks to overwrite the Entity-Class, but i dont want to loose my changes.

Any ideas to this scenario? I believe iam not the only one who make manual changes.

Thanks in Advance for any hints and apologise my english, its not my mothers tongue.

Re: resync Tables to Entities? [message #502837 is a reply to message #502797] Wed, 09 December 2009 20:58 Go to previous messageGo to next message
Matty  is currently offline Matty Friend
Messages: 4
Registered: December 2009
Junior Member
Wow Neil, your answer is more than i've ever expected.Thanks a lot for your advice and your hints to my question.

Mhmm..i understand your explanation about using dali in the first steps of development for example to prototyping or to find a easy entry into a project with existig db schemas.

But it is a possiblity (for my scenario) to inherit the generated Entity-Class and add there my NamedQuery for example?

How could i do this in the JPA "framework"? Iam new to EJB 3 too as i written. Rolling Eyes

Thanks in Advance again
Re: resync Tables to Entities? [message #503027 is a reply to message #502837] Thu, 10 December 2009 15:58 Go to previous messageGo to next message
Neil Hauge is currently offline Neil HaugeFriend
Messages: 475
Registered: July 2009
Senior Member
That sounds like a bad approach. Getting involved with entity inheritance for the wrong reasons will end up being more problematic than simply editing existing entities. I would also not advise using inheritance for this purpose alone in your model.

Neil
Re: resync Tables to Entities? [message #503084 is a reply to message #503027] Thu, 10 December 2009 19:47 Go to previous message
Neil Hauge is currently offline Neil HaugeFriend
Messages: 475
Registered: July 2009
Senior Member
One thing you could do is put your named queries in an orm.xml mapping file. This mapping file is not currently affected by Entity Generation from Tables.

Hope this helps,
Neil
Previous Topic:Customize Composite Key Names
Next Topic:JPA NamedQuery Result
Goto Forum:
  


Current Time: Thu Mar 28 12:36:29 GMT 2024

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

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

Back to the top