This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I started working on a sample and simple hibernate application, that will persist "Person" objects and have few questions regarding this. I'm listing out the questions below:
Please find the following components
Q 1) When I run my client any time, I see only 5 objects being persisted? Why? Every time it runs, my assumption is,it should persist 5 objects and thus increasing the total count of persisted objects. I get the same thing, even I use a completely new session while retrieving "Person"s from the database.
Q 2) After every run, I'm trying to look into hsqldb (this is database used) but I do not see any table being created by name "PERSON". Am I looking at the right spot?
Q 3) If I remove "hibernate.hbm2ddl.auto" from configuration file, and run the client I get that table does not exist. I can understand this, because I did not find any table (see question 2). But why the table is not created.
Q 4) If I create a table PERSON explicitly and remove "hibernate.hbm2ddl.auto" from configuration file, and run the client, I get can not insert NULL into ID. Why is hibernate trying to insert null at first place for ID field.
Q 5) If I want to use a composite key, what do I need to modify?