Posts

Hibernate-4

Image
6.Query languages Q-A)Why we need a query language in hibernate. for join quires. for update PK. JPQL queries can use in HQL,But HQL queries cant use JPQL. SQL queries cant use in JPQL & JPQL  queries cant use in SQL. SQL include all DDL,DML quires. But JPQL & HQL include DML quires. JPQL include UPDATE,DELETE,SELECT quires. HQL include UPDATE,DELETE,SELECT,INSERT INTO... SELECT quires.  NH Vs JPAH differences in session vs entity manager                     Should be considered:-(R):return type                                                                :-(Q):query language 1.Get data CreateQuery vs CreateQuery (R)Query/TypeQuery vs Query/TypeQuery (Q)JPQL/HQL vs JPQL(Cant use for the SQL) 2.List of data list() vs getResultList() 3.UniqueResult(0 vs getSingleResult() 4.addEntity vs <not define> 5.getNameQuery  vs createNamedQuery 6.getNamedNativeQuery Vs CreateNameQuery Parameters Using mixture of these parameters is no not a good practice a)Positional Parameters use

Hibernate-3

Image
Cont..Hibernate-2  (5.2)By-Directional Relationship In a bi-directional relation both sides know about the other side.So both sides can access another side. Owner end data can fetch using inverse end & inverse end data can fetch using owner end Criteria:      1. Selection of one entity to exchange pk to fk or DBMS  rules      2.Using @JoinTable      3.Decomposing    (1)1-1 Relationship 1-1(Total participation) 1. Selection of one entity to exchange pk to fk or DBMS  rules Girl.java @NoArgsConstructor @AllArgsConstructor @Getter @Setter @ToString @Entity public class Girl {      @Id      private int id;      private String name;      @OneToOne //If do not add unique=true it will be not a 1-1 relationship,It will be 1-m      @JoinColumn(name="boy_id", referencedColumnName = "id",unique = true)      private Boy boy; } Boy.java @NoArgsConstructor @AllArgsConstructor @Getter @Setter @ToString(exclude = "girl") @Entity public class Boy {     @Id     pr

Hibernate-2

Image
 count from....Hibernate-1 JPAH-JPA Hibernate NH-Native Hibernate 4.Persistence Context & Persistence State   Persistence State:Forms of entity which will navigate the hibernate. 1.Transient State New records are stored as transient state 2.Detached State If there is any content in the detached state it must be in the DB. merge detached entity step 1-create a clone from detached entity,but dont know the memory location of that entity. step2-using select query check weather availability  of the record. step 3-merge with the persistence context's entity.  3.Managed State If the entity is in persistence context will called as the manage state,In this state dirty checking feature activated in the entity object.If we want to update any thing in the db we want to put that in to the persistence context.All the content in the persistence context will flush(),after the commit  session.contains(entity name-->Check whether entity is in the persistence context) After fetched(get or find

SQL Transaction

Image
1.What is a transaction Simply it groups of database quires. A database transaction symbolizes a unit of work performed(Operations:Read Write) within a database management system (or similar system) against a database, and treated in a coherent and reliable way independent of other transactions. 2.why do we need transaction Group of read write operation;which independent from other operations. Do not execute part of  transaction.If execute all or none. Eg:-Credit debit operation in ATM management system. 3.Serial Schedule Transaction Vs Serializable Schedule transaction *A complete schedule* is a schedule that contains either an abort or a commit for each transaction in the set. *A serial schedule* is a schedule that the actions of different transactions are not interleaved, that is transactions are executed from start to finish, one by one. *A serializable schedule* over a set S of committed transactions is a schedule whose effect on any consistent database instance is guaranteed to

Garbage Collection in JAVA

Image
There part 2 parts of multi tasking in Computer science.    1. process based multi tasking. process :Simply any program run in OS called process, Self contain execution environment .(A private set of basic runtime resources;allocate memory space for each every program in RAM Stack)Thus we can run many program in one now a days OS's which means process based multi tasking.process allocate memory space for the program     2.Thread based multi Tasking. Threads :Any  code context has a thread.thread will execute the code.So some of thread can execute 2 or more program concurrency that called Thread based multi Tasking.Also   light weigh process, because It takes less memory space compare to the processes . Garbage collector Each & every thread  has a specific stack.So stack is thread safety(Stack store local variables & parameters so they are thread safe),but heap is not(Objects are not thread safe).As well as heap is common.So there is a tendency to overflow the heap.so there

Obscuring

Definition:A simple name may occur in contexts where it may potentially be interpreted as the name of a variable, a type,type parameter, or a package.(JLS-8).So it will be course to compile time error,will define as the obscuring. This is another problem that arises due to sharing the same name for a variable and a class in Java. //compile-time error in last line public class A {     public static void main(String[] args) {         String System = "Obscuring Exsample";         System.out.println(System);     } } Solution:Use Proper Naming convention.

Hibernate-1

Image
1.INTRODUCTION Java EE(Enterprise edition Java) Simply EE focus to develop enterprise application development.The aim of the Java EE platform is to provide developers with a powerful set of APIs while shortening development time, reducing application complexity, and improving application performance. Java EE vs Java SE JDK(Java Development Kit)     Java SE API     JRE(JVM)     Development Tools(Eg:-Javac,Serial version UID,etc) Java EE based on java SE.In the java SE we can develop anything;Also EE application but that develop must concern cross cutting component.But in the Java EE developer can focus one develop the business logic, Lesley thinking about security,transaction,error handling,login etc. JAVA SE gives a collection of specification(like documentation)+their implementation. JAVA SE gives  only specification.So several external companies implement that methods several ways Eg:-Hibernate,Jetty,Apache Tom Cat,Glass fish                      Companies implement java EE specific