Beruflich Dokumente
Kultur Dokumente
q2]
Entity is when a group of states are assosciated together in a single
unit.Each entity associated with a metadata
and the metadata represents the information of it.The metadata can exist inside or
outside of the class.
An example of an Entity
Example for Entity:
import javax.persistence.*;
@Entity
public class Student {
@Id
----------------------------------------------
q3]
-A session is used to get a physical connection with database.
-A session object is lightweight and designed to be instatiated each time an
interaction is needed with the database
-It is a short lived object and wraps a jdbc connection.It is a factory of
Transaction query and Criteria.
Persistent objects are saved and retrieved through a Session object.
1]Transaction beginTransaction()
Begin a unit of work and return the associated Transaction object.
2]
void cancelQuery()
Cancel the execution of the current query.
3]
Query createFilter(Object collection, String queryString)
Create a new instance of Query for the given collection and filter
string.
4]
Criteria createCriteria(String entityName)
Create a new Criteria instance, for the given entity name.
5]
Connection close()
End the session by releasing the JDBC connection and cleaning up.
6]
Criteria createCriteria(Class persistentClass)
Create a new Criteria instance, for the given entity class, or a superclass of an
entity class.
7]
Serializable getIdentifier(Object object)
Return the identifier value of the given entity as associated with this session.
8]void delete(Object Object)
delete persistant instance fro the database
------------------------------------------------------
q4]The cfg file or the configuration file give the information about the database
and mapping file.
the file is called hibernate.cfg.xml
---------------------------------------------------------------
7]
@column annotation describes
It is type of defining mapping without the use of mapping files.
It helps to replace mapping of xml mapping metadata.
there are many annotations that is used to create hibernate applications like
@id,@entity.
@Column annotation specifies the details of the column for this property or field.
If @Column annotation is not specified, property name will be used as the column
name by default.
------------------------------------------------------------
8]Steps to create configure files in a project.
The configuration file contains all the informations for the database such as
connection_url, driver_class, username,password etc.
The hbm2ddl.auto property is used to create the table in the
database automatically.
To create the configuration file, right click on src - new file. Now specify the
configuration file name e.g. hibernate.cfg.xml.
------------------------------------------------------
9]session.saveOrUpdate(Object object)
it is afuntion which is used to save or update the given instance.
It can either insert or update based on the exitence of of record.It can bring
transient and detached object to persistent state.It often reattach a detached
object into session.
--------------------------------------------------
10]When transaction is commited.
It makes permenent changes which is performed by the sql commands within the
transaction.It flushes the session.
------------------------------------------------------