I am trying to get my head around how to represent a back end SQL database using beans, how do entities fit in with beans? Do beans act as a portable container for database entities, like a customer entry?
Asked
Active
Viewed 68 times
0
-
Have you looked at the [tutorial](http://docs.oracle.com/javaee/7/tutorial/persistence-intro001.htm#BNBQA)? – mabi May 26 '16 at 10:14
-
I haven't yet, and I will now, thanks! – Sam May 26 '16 at 10:14
-
I've read the tutorial and I'm still confused. Is there a hierarchy betwen POJO, entity and bean? Are they that related or are they more independent of each other? – Sam May 26 '16 at 10:30
-
Thanks for linking a question which doesn't answer my question. The one linked has one answer that contains Entity and doesn't explain the relationship between entity and bean, so doesn't answer my question. – Sam May 26 '16 at 12:51
-
not sure what you mean by "hierarchy". All entity beans are beans (obviously), and nowadays all beans are also POJOs. Each bean (quoting the tutorial) usually relates to a table. Those are all concepts describing what a class should contain. I suggest working through the examples from the tutorial and opening questions for the parts you don't understand. – mabi May 26 '16 at 13:15
-
I think the the loose definitions I'm struggling with, for a single name POJO's and beans seem to be rather ubiquitous for something with only one name. When I say hierarchy I mean how do they fit together, because there seems to be a lot of overlap of definitions which I'm not 100% on. Thanks for your help by the way! – Sam May 26 '16 at 13:34
-
1That's because (as explained in the duplicate), Beans are a sub-set of POJOs (which is just a nifty way of saying "any class you write today"). They need to conform to the JavaBean standard, and this convenience property definition is used by specifications like JPA to attach meaning to those fields. – mabi May 26 '16 at 13:42
-
That's exactly what I meant by hierarchy, I was trying trying to see how the definition of bean and that of POJO fit together, and that's helped me understand, thanks! From what I understand, a POJO is a very high level term for a variety of classes with a few similar characteristics, such as being serializable, having a no arg constructor, and access to getters/setters. Thanks @mabi – Sam May 31 '16 at 10:23
-
1Nah, POJO really means *any* object. It's the *absence* of certain conventions that makes it "plain". Refer to the [wiki](https://en.wikipedia.org/wiki/Plain_Old_Java_Object) article on it, it has some historical context as well as a relation to the JavaBean standard. – mabi May 31 '16 at 10:37