Documentos de Académico
Documentos de Profesional
Documentos de Cultura
The State Of an Object Can be Saved to a Data store , and re-created at a later
point in time.
Way To Store Data
1. File
2. Relational DataBase
Relational DataBase :DataStore That represents Data in Table like Format.
--SQL Used to Manage data in RDBMS.
-- In each RdBMS Table 2 Rule follow
1. Entity Integrity (PK with NOT NULL value)
2. Referential Integrity (PK FK)
Java :Object Model
Having Poly,encu,data hiding feature.
Object is an instance of class which having indetity,state ,behaviour.
RDBMS : Relational Mobel
Define Data Structure , data Manipulation , Data integrity
Data Are present in form of table that are connected using referential integrity
Section 2 :
Object Relational Impedance Mismatch :
Loading or storing of Object using a relational database having 5 major Mismatch
:
1. Granularity :System could be broken down into small parts.
In Object Model Various Level
IN RM only Two
1. Tables 2.Columns
2. SubType/inheritance
OM : Yes
RM : No
3. Identity :
OM: Ob identity(address) / Ob equality(Value)
RM : Same of two entity difne by PK
4. assocations:
OM : ob reference / Bi-directional
RM : FK/directional
5. Data Navigation
Data Access
---------------------------------OR Mapping :
Problem :
1. Write SQL code by Developer.
2. JDBC API
3. To many copy of code.
4. Sql code depaend of RDMS(My SqL) ,if want to change other RDMS then problem.
To Solve it : ORM(object relational Mapping)
The representation of data from java Objects to Relational database.(visa versa
)
ORM allows use Java Objects as representation of a RD.
Mapping between POJO and RD.(use XML/Annotation)
hibernate.org/orm/
lib/req folder
-------------------------------------------------ALL
OFF
----------------------------Transactions : group of operation that are run as a single unit work.
--------------------------------Aggergation :
relationship between a whole and it's part.
Compostion
Strong from of above.
if one distory whole will destory.
Entity : its own database identity(PK)
Values Type : No ------------,belongs to entity.
persistance classes don't have their own database identity.
---------------------------------------(component Mapping) :
@Embedded
@Embeddable
-------------------------------if table anotation is missing then by default it will use enitity name.
similer column
----------------------------------Cascades :(transitive persistance
many time call the save method for each object.
use persist() method;
-------------------------------OTM relationshipship : is not the OWNER Of the relationship.(inverse end)
In bi-directional OTM one of side has to be OWNER which is responsible for assc
iation column update.
OWNER : entity who is persist with FK
------------------------------ OTO---------------------i.e. Passport and customer
Bi directional , so one is owner
MTM
movie < ---- >actor
--------------------- JPA--------------------Hibernate having its own Native API which haiving implements also and use as JPI
provider(session.sesssionfactory configuration)
but JPA having only Native API no implements on it .
------------------- Working with Objects----------ob = new class_name -->transient state (no assoicate with any database row)
-- exist only in JVM
.persist(ob) --> persistent object(having database identity)
-- exist in JVM/Persistent context(Entity Manager) First Level Cache
-- manage by EM during trx.
with write lock no other trx. and user can see data / update data
-------------------------- ISOation Levels ----------------extent to which a trx. is visible to other trx.
4 type of level
1. serializable : same as before.
trx excute serial. once is commited then other trx effected relfected in other t
rx.
-- slow performance
2. Repeatable_read : same data but only inserted data
phantom reads.
3. read_committed
both will get inseeted and updated as well.
4. read_uncommited(dirty read)
same result before.
but trx 2 not commited but also reflected.
we can also rollback this updated.
-----------------------------------------------------------------