Hibernate allows us to compose our components out of other components. This is making extreme use of java in the SQL world, but provides us with a great deal of flexibility. I modified the address class in the previous example to be composed of components.
Search This Blog
Sunday, 30 October 2011
Friday, 28 October 2011
Ordered Collection
In an earlier post we saw that hibernate provides us with the option to use Sorted Collections. In these collections the objects were fetched form the database and inserted into collections in a sorted order. Thus the sorting of elements happened in the Java Domain. This was an example of in-memory sorting.
Hibernate also provides an alternative to the above technique called ordered collections.
Hibernate also provides an alternative to the above technique called ordered collections.
Friday, 21 October 2011
Hibernate Collections - The whole variety -2
In the last post we saw a java class that included the different collections supported in Hibernate and the mapping file. If we were to start the server with the hibernate set to DDL creation then the logs are as below:
Exception in thread "main" org.hibernate.InvalidMappingException:
Saturday, 15 October 2011
Hibernate Collections - The whole variety -1
In the previous post we saw the varied collections available for use in Hibernate. I created a class which includes the different collection types.
public class Person { private Long id; private String name;
Wednesday, 12 October 2011
Hibernate And Collections Support
Hibernate supports the use of Collections in the Java model objects. Associations between tables are represented using these collections.
e.g.: If there is a one-to-many relation between owner and pet (1 Owner has many pets) then a collection of pets can be mapped in the Owner class.
e.g.: If there is a one-to-many relation between owner and pet (1 Owner has many pets) then a collection of pets can be mapped in the Owner class.
class Owner { private List<Pet> pets = new ArrayList<Pet>(); }
Subscribe to:
Posts (Atom)