vohoanghiep103 / vaadin-appfoundation

Automatically exported from code.google.com/p/vaadin-appfoundation
0 stars 0 forks source link

NullPointerException on retreiving data #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

I'm using the AppFoundation add-on to add persistence to the address book
demo. I've followed the instructions given on:

http://devblog.mycorner.fi/18/adding-jpa-based-persistence-to-the-address-book-d
emo/

However im getting a NullPointerException when im trying to fetch the data
from my database. I have also looked at the source code for the example.
The NullPointerException occurs at:

List<City> cities = FacadeFactory.getFacade().list(City.class);

In my case im using an entity class City instead of Person.

I have my db set up with the correct config as described on the
AppFoundation documentation. The table exists on the database with sample data.

I only want to read from the table and update it so i have changed the
persistence/xml file accordingly:

<property name="eclipselink.ddl-generation" value="none" />

Any ideas why im getting the NullPointerException?

I have highlighted the issue at:

http://vaadin.com/forum/-/message_boards/message/156435

Thanks

Original issue reported on code.google.com by albasoft...@gmail.com on 8 May 2010 at 9:55

GoogleCodeExporter commented 9 years ago
I've written a reply in thread linked in this ticket.

Original comment by kimp...@gmail.com on 9 May 2010 at 7:03

GoogleCodeExporter commented 9 years ago
thanks kim. 

after posting the details of the error i noticed that i was missing the listner 
entry
in web.xml.

Im now getting another error when mysql is doing a select on my table: 

Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
Unknown column 'ID' in 'field list'
Error Code: 1054

Do i have to set the primary key to a column named ID? 

Original comment by albasoft...@gmail.com on 10 May 2010 at 10:20

GoogleCodeExporter commented 9 years ago
ok, ive renamed my primary key to ID, however i was getting an error about the
CONSISTENCYVERSION. Once i added a CONSISTENCYVERSION column to my table it 
worked
successfully. 

Does this mean that for every table i have which i want to read, update and 
delete
from i need to have the primary key column names ID and a CONSISTENCYVERSION 
column?

Original comment by albasoft...@gmail.com on 10 May 2010 at 11:42

GoogleCodeExporter commented 9 years ago
Unfortunately, yes it does. The facade needs the id field for fetching data and 
the
consistency version field is used for optimistic locking.

Original comment by kimp...@gmail.com on 10 May 2010 at 5:21

GoogleCodeExporter commented 9 years ago
I should probably mention this in the documentation, as some people (like you) 
might
not use auto-generated database structures. Thanks!

Original comment by kimp...@gmail.com on 10 May 2010 at 5:25

GoogleCodeExporter commented 9 years ago
ok, that makes sense. I do have it working now and I must say that im really 
liking
this add-on. 

Thanks!

Original comment by albasoft...@gmail.com on 11 May 2010 at 9:07

GoogleCodeExporter commented 9 years ago
Fixed in the documentation of 1.3.2

Original comment by kimp...@gmail.com on 16 Jun 2010 at 5:57