I'm a first-timer to this and would like to have some guidance regarding how to store objects in a database..
I have an object Person
, with a couple of fields in it. I have one PersonContainer
which loads all the objects from the database.
What is best of these two: (or if they both suck, tell me what's the right thing to do)
Store the object just as a XXX.store(new Person())
or
Store the object as in XXX.store(new BeanItem<Person>(ne开发者_Python百科w Person()))
?
Whats "good practice" to do?
My recommendation would be to persist Business objects i.e. objects that represent a business concept of your particular domain, in your case Person
, etc.
Actually, I suggest to have a look at the Adding JPA to the Address Book Demo page in the Vaadin wiki, you might find some useful information there.
I would also suggest to persist Person. The BeanItem class is used by Vaadin for its own purposes (binding etc) so there is no reason to persist those "vaadin purposes" :)
SC
精彩评论