A) hibernate meaning
In a real ooad, our design is first to do the UML, and eventually a system involving all objects (this thing is not so simple) with a class diagram to represent a complete design, we may end up with these types: control of business logic classes, class module (Bean Class), helper class, or more (specific problem analysis for the business data), but it is more suitable for tiering to boil down business data to a class module. When the database is implemented at a lower level,
To get the data or to store the data, you have to add a control logic to manipulate the database, so your perfect design is expected to make a huge effort, because the business data layer you see is a complex module, even from an object-oriented standpoint, our UML class diagram, The business data tier is just a data module. Hibernate has helped us solve the underlying implementation of this inherently complex module of the business data tier, and now we just wrap the outer layer with our representative data class.
Difference between object model and relational database model
I think it is necessary to write down this section before writing my first probe into the feelings of hibernate. Research with questions is far more far-reaching than a curious study.
Problem areas:
Relational database is the best choice for storing data, but with the development of OO technology, the relational database design system in the persisitent layer is out of tune with OO system, and it can be imagined how painful the expression is when you think about how to isolate the SQL statement that is filled with ooad. No matter how perfect your business layer design is, when you're actually storing data or loading data, you're dealing with a lot of encapsulated data that has completely lost its meaning in JDBC (where the object is called a business object, perhaps more precise), and your overall ooad ends here. Why is this happening? The reason is the difference between the object model and the fundamental design system of the relational database model.
The theoretical starting point of the object model and the relational database model is different: the theoretical system of the object model can be simply summed up in these two points:
1 treat the world with objects.
2 The relationship between objects (inheritance, association, aggregation, combination) sustains the overall composition.
The relational database model is the only starting point is the effective storage of data, key is a critical database technology, the relationship here is just the link between the key of the data table, this association I think should be called the correlation of data, the meaning of its expression is far from the relationship between the objects so deep.
So, the question I'm most concerned about is how Hibernate uses the relational database's data Table key Association to express the relationships between objects?
Before entering into the formal research hbernate, we can consider the seemingly simple and seemingly complex contradictions of the question.
All the classes we have designed to represent the data layer must be perfectly reflected in the datasheet. You can summarize this:
Class-àtable
class1-(Relationship)---class2------〉table1---(relationship)-----table2
The solution to the problem seems simple, especially for the JavaBean architecture, which is simple (seemingly simple)!!! )。
Imagine a simple JavaBean class:
public class SimpleBean{
protected int id;
protected String name;
public int getId(){
return id;
}
public void setId(int id){
this.id=id;
}
public String getName(){
return name;
}
public void setName(String name){
this,name=name;
}
}
We can do the name mapping in this way:
className-àtableName
propertyNameàcolumnName