NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Entity classes from (SQLite) DB - am I missing something obvious?

 
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users
View previous topic :: View next topic  
Author Message
LĂșthien



Joined: 27 Sep 2011
Posts: 5

PostPosted: Tue Sep 27, 2011 9:45 pm    Post subject: Entity classes from (SQLite) DB - am I missing something obvious? Reply with quote

Hi,

about a year ago I used netbeans' "generate Entity classes from database" feature successfully on a Derby database.
The past week I've tried to do the same thing, this time using a SQLite database. Maybe I'm overlooking something obvious, but I can't get it to work this time.
I'm using SQLite v. 3.7.6 and Netbeans 7.0.1, on OSX Lion, using java version 1.6.0_26 .

I tried all sorts of things that I could find that had helped others who had problems with this feature: tried it on tables with integer and varchar PK fields, with or without foreign keys attached, table names lowercase or uppercase. I've used both the Context menu -> New -> Entity classes from DB and the Context menu -> New -> Master/Detail sample form.

This is what happens:

- if I try the Context menu -> New -> Entity classes from DB - first having opened the SQLite connection on the "Services" tab, I can choose the correct Database connection and see all tables listed under 'Available Tables'. None of them is, however, selectable. It says "(no primary key)" behind the table names - even though I'm certain that there ARE primary keys defined on those tables.
- if I try the new Master/Detail sample form, it should also generate an entity class. Here, I can select a table, and it shows up correctly, with all columns. The wizard creates three classes: a GUI form, a <tablename>.java entity class, and a <tablename>PK.java class.

The <tablename>PK.java class is broken: it has two identical constructors, and an invalid toString() method, which returns (ERROR):

Code:
  public EntryPK() {
  }

  public EntryPK() {
  }

  (equals() & hashCode @overrides)

  @Override
  public String toString() {
    return (ERROR);
  }


The <tablename>.java class looks ok to me, but when I correct the above errors in the -PK file (removing the double constructor, and fixing the toString() method, I get a javax.persistence.PersistenceException when trying to run the form:

Code:
Exception in thread "AWT-EventQueue-0" javax.persistence.PersistenceException: No Persistence provider for EntityManager named ithildin_pu: Provider named oracle.toplink.essentials.PersistenceProvider threw unexpected exception at create EntityManagerFactory:
oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
Local Exception Stack:
Exception [TOPLINK-30005] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@b92d342
Internal Exception: javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
Exception Description: predeploy for PersistenceUnit [ithildin_pu] failed.
Internal Exception: Exception [TOPLINK-7249] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: Entity [class dict.Entry] uses [class dict.EntryPK] as embedded id class whose access-type has been determined as [FIELD]. But [class dict.EntrytPK] does not define any [FIELD]. It is likely that you have not provided sufficient metadata in your id class [class dict.EntryPK].
   at
(...)


This part: "Entity [class dict.Entry] uses [class dict.EntryPK] as embedded id class whose access-type has been determined as [FIELD]. But [class dict.EntryPK] does not define any [FIELD]. It is likely that you have not provided sufficient metadata in your id class ..." suggests that I should change that ID class somehow, but it's a bit like trying to find a dark cat in a dark room this way Smile

Does anyone have a hint how I could make this work?

Thanks in advance!

LĂșthien

PS oh yes, something that I noticed was that the Entity classes that I generated last year on that Derby DB did not only work fine, but also that there weren't any <tablename>PK.java classes around or needed. There are just the <tablename>.java ones. I haven't yet figured out what that means.
Back to top
LĂșthien



Joined: 27 Sep 2011
Posts: 5

PostPosted: Tue Sep 27, 2011 10:53 pm    Post subject: Reply with quote

Update - When I created another project in Netbeans, and tried to build a Database Application Example form right when creating the project, it did work; generating a correct Entity class and EntityPK class. It also runs correctly, showing the table data.

When I try to generate entity classes after that however, it still has the same problem as before. Also, trying to create another new Master/Detail sample form still fails.
Back to top
twimnox



Joined: 24 Nov 2016
Posts: 1

PostPosted: Thu Nov 24, 2016 12:18 pm    Post subject: It's 2016 and I'm facing the same problem Reply with quote

Hello all. It's been a while since this thread was opened, but since I'm facing the same problem now I'd like to ask if you guys came up with any solution for that.

Tyvm.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo