Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Generate Entities from Tables (Postgres 8.4)

Sounds like the tool you use to generate the object model from the tables did
not generate the model correctly.  You may try posting to Dali Eclipse
forum.  EclipseLink does not generate entities from tables.

In general, the object model generated directly from tables, is normally not
ideal, and it is normally better to design the object model from your
application's requirements.

If you are having specific issues, please post them separately with enough
details for someone to understand them.  In general it seems you will need
to edit you object model and its annotations to some degree.


greatkalu wrote:
> 
> Hi all,
> 
> I'm not sure where to ask this, so if I'm in the wrong place, apologies in
> advance.
> 
> I have built a large database in PostgreSQL 8.4, with quite a few Stored
> Functions, Triggers, etc. in order to increase the performance of my
> application and for functional requirements such as avoiding gaps in some
> sequences.
> 
> I've build Java EE applications before on NetBeans, but have chosen
> Eclipse for obvious reasons. I've been following the following tutorial:
> 
> http://programming.manessinger.com/tutorials/an-eclipse-glassfish-java-ee-6-tutorial/
> 
> ... in order to get around some specifics, but I've run into a problem at
> the first hurdle which I cannot seem to figure out.
> 
> When generating entities from my database, the resulting Entity Beans are
> full of errors: some tables are not even generated even though I selected
> all tables in the wizard.
> 
> I think the main reason is that I do not have a fixed structure of tables
> in my database. For example, some tables have up to 4 columns as a
> collective primary key, while others have just a column and a row to store
> a count variable. The database indexing is fine as it is and can run
> without any problems on its own. I tried all types of key generation in
> the wizard: auto, identity, table, none (didn't try sequence because not
> all of my tables user Postres' sequencing system).
> 
> I'm mostly planning on building the front end (Swing) and finishing off
> the smaller (quicker) business logic through Session and Message-Driven
> beans.
> 
> So that is a basic intro of the state I'm in. There are quite a few errors
> ... I'll list the ones I've noted as of now:
> 
> 1) Some tables are not generated as entity beans.
> 2) Some associations generate naming errors: So far, I've only noted SOME
> @ManyToOne associations. I'll go into more detail here.
> 
> In the Table Associations frame of the Entity Generation wizard, I've
> noted a ManyToOne relation. The Table join section seems fine, as do the
> properties of both tables involved.
> 
> Eg: accountTransactCenter.currencyId = currency.id
> 
> However, AccountTransactCenter.java has the following error:
> 
> //bi-directional many-to-one association to Currency
> @ManyToOne --> error
> @JoinColumns({})
> private Currency currency;
> 
> Mouse-over the error: Join column "currency_id" cannot be resoved on table
> "accountTransactCenter"
> 
> Now, I made a few errors in my DB development. Mainly, naming errors. I
> followed java method style, starting all DB identifiers with lowercase
> with an proceeding word beginning with an upper case. Postgres supports
> identifiers with uppercase characters by double-quoting them. As I was
> using a GUI client in pgadminIII, I only noticed this when I had done
> quite a bit of work.
> 
> Secondly, and I do not think this is an error, I name my foreign keys as
> such:
> 
> localTable_foreignTable_foreignTableColumnName.
> 
> This could be the only reason I can think of as to why currency_id was
> raised in the error, as I had not entered any such name into a column or
> table name. Are my suspicions correct? So, for the example given, the
> foreign key in accountTransactCenter would be:
> 
> fki_accountTransactCenter_currency_id (fki is generated by Postgres).
> 
> Other than this, I haven't found anything else. I know I should have tried
> an easier example before building my whole database, but is there any way
> around these issues?
> 
> I should state that I'm using EclipseLink for JPA 2.0 on Indigo, Postgres'
> jdbc4 driver which is working well and have tested both Linux and Windows
> OSs.
> 
> I will try using Hibernate as my persistence provider, then an older
> TopLink. Hopefully, something will come through.
> 
> I should also add that I'm running a glassfish 3.1.1 application server.
> 
> Any help/comments would be greatly appreciated.
> 
> Thanks and best regards.
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.eclipse.org/forums/index.php?t=thread&frm_id=111&S=1b00bfd151289b297688823a00683aca
EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
Blog:  http://java-persistence-performance.blogspot.com/ Java Persistence
Performance 
-- 
View this message in context: http://old.nabble.com/Generate-Entities-from-Tables-%28Postgres-8.4%29-tp33544734p33544873.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top