Tuesday, July 30, 2013

Features of Hibernate and Hibernate features


1. Light weight ORM Framework Software.
2. Allows us to Database software independent persistence(o-r mapping persistence logic)
3. Supports POJO and POJI model programming.
4. Can be used along with Java, JEE, Java Framework software applications to make them
internally with ORM software.
5. Gives built in JDBC Connection pool also allows to work with third party supplied and
server managed JDBC Connection pool.
6. Gives built in transaction management support and also allow working with server
managed Transaction management.
Note: Hibernate gives built-in middleware service and also allowed to work with third party
or server supplied middleware services.
Note: Middleware services are additional and optional services which can be applied to our
application to make our application running smoothly in all sitchuations.
EX: Transaction Management, Security, JDBC Connection Pooling and e.t.c.,
7. Gives the records of the table directly in the form of Collection Framework data
structures which are serializable objects by default.
8. Gives the Database software independent query language called HQL.
9. Also allows using direct SQL queries to develop persistence logic.
10. Throws only un checked exceptions so Exception Handling while developing Hibernate
persistence logic is optional.
Note: Even though Hibernate uses JDBC and even though JDBC code throws Checked
exceptions the Hibernate software converts them to unchecked exceptions by using
Exception Rethrowing concept.
public void bml()
try
{
------------- source code which may checked exception
-------------
}
Catch(SQLException se)
{
Throw new arithmetic exception();// Exception Rethrowing
}
}
11. Allows us to develop PL/SQL procedures/ functions of Database software.
12. Allows to build object based relationship one to one, one to many and e.t.c.,
13. Gives annotations support in programming as alternate to XML files.
Note: Annotations are Java statements that are alternate for the XML file resources
configuration and other applications
14. Also supports JPA standards of o-r mapping persistence logic development
Note: JPA defines set of rules and guidelines that are required to develop ORM softwares
due to this programmers can work with all these ORM Softwares in a common way.
15. Easy to communicate and apply.
16. Supports two levels catching and buffering.
Note: Buffering in Hibernate based client application reduces the network round trips
between client and server.

Hibernate interms of JDBC program:


Understanding Hibernate abstraction layer on JDBC program:
1. Register JDBC driver with DriverManager service.
2. Establish connection with Database software.
3. Create JDBC statement object.
4. Send and execute query in Database software.
5. Gather results and process the results.
6. Close JBDC objects.
7. Take care of Exception handling.
8. Perform Transaction management (if necessary).
1,2,3,6,7 and 8 are common logics because they are always same in JDBC based Java
applications.
4,5 are application specific logics because they vary in each JDBC based application.

hibernate framework definition


Framework: Framework is special software that is built on the top of core technologies having
the ability to generate the common logics of the applications dynamically while working with
Framework softwares.
1. Programmer just develops application specific logics because the Framework software
automatically generates the common logics of application dynamically by using core
technologies internally.
2. Framework software provides abstraction layer core technologies internally generate
some common logic but they never make programmer bothering or knowing about these
core technologies.
EX: Hibernate, Struts, Spring.

technical definition of hibernate interms of database


Hibernate is open source lightweight Java based ORM software to develop
object based Database software independent o-r mapping persistence logic in Java, Jee and Java
Framework software based applications.
1. When hibernate software is installed it gives its source code to programmers and
moreover Hibernate is free software due to this we say Hibernate is opensource software
2. EJB Components are heavy weight components because they need heavy weight
container, server softwares for execution.
3. The resources of EJB components are EJB API dependencies. Hibernate software and
Hibernate components are light weight because to execute Hibernate applications we use
just JDK software, Hibernate Software and there is no need of working with the heavy
weight containers, server softwares.
4. Some resources of Hibernate applications can be developed without using Hibernate API.
5. We can write Hibernate logic in any kind of Java applications to make them taking with
Database Software.

Wednesday, July 24, 2013

Object Database Software in hibernate

Object Database Software: The Database software which can store software object as Database
table column value is called Object Database Software.
public class marks
{
-------------
---------------
}
marks mk=new marks();
mk(marks class obj)
Object Database Software
Object Database softwares failed in the industry because of following reasons.
i. They store multiple values in the single Database table column as software object but
storing multiple values in single Database table columns is against of normalization rule
number 1.
ii. Generating reports from the Database table of Object Database softwares is complex
process.
Note: SQL Queries are Database dependent queries.
m1=30
m2=50
m3=70
Student Tab(Database Tabel)
Sno sname     marks
10 Siva         m1=30, m2=50, m3=70
11 kumar
12 Reddy

Java application can use either JDBC or o-r mapping concepts to develop JDBC mapping
concepts and to interact with Database softwares. In small scale organizations we use files as
persistent stores and use I/O Streams to develop the persistent logic.
EX: Desktop games and mobile games.
In medium scale organizations Database software is used as persistence store ad JDBC to
develop the persistence logic.
EX: Office automation application.
Payroll applications
Library management application and e.t.c.,
In Large scale organizations Database software used as persistent store and use or mapping
style persistent logic.
EX: Banking applications/credit card applications and e.t.c.,
Drawbacks of JDBC:
1. SQL Queries are Database software dependent queries. JDBC uses SQL Queries so
JDBC persistent logic is Database software persistent.
2. Changing Database software in the middle of project development or production
environment is complex process.
3. All Exceptions in JDBC programming are checked exceptions we must catch and handle
those exceptions.
4. JDBC supplied Middleware services but those are not sufficient not good for industry
standard projects.
5. Middleware services are security transaction JDBC connection pooling and e.t.c., to
overcome all the above problems we use o-r mapping persistence logic instead of JDBC
persistence logic.
6. The Parameters of PreparedStatememnt related SQL query allows only positional
parameters (?) and they does not allow named parameters.
7. We can send only Serializable Java objects over the network. JDBC ResultSet object
can’t be sent over the network because it is not serializable object.
8. In JDBC programmer have to Write more common logics along with application
specific logics in every JDBC application (Scratch level coding is required).

Monday, July 22, 2013

persistent objects in hibernate

Persistency: The place where data can be saved permanently is called persistent store.
EX: Files, Database software
Insert, update, delete and select operations on persistent stores to manipulate data are called
persistence operations. These operations are also called a CURD or CRUD or SCUD operations.
CURD:
C--Create (insert)
U--Update
R--Read (Select)
D--Delete
CRUD:
C---Create (insert)
R---Read (Select)
U---Update
D---Delete
SCUD:
S---Select
C---Create
U---Update
D---Delete
Logic written in software application to interact with persistent store and perform persistent
operations is called persistence logic.
EX: JDBC Code, Hibernate Code, I/O Stream Code and e.t.c.,
Presentation Logic: The logic that generates user interface for end user is called presentation
logic. End user uses this user interface to supply inputs to application and to view results given
by application. (OR)
To view formatted results given by application. The main logic of application that generates
results based on given inputs is called business logic.
Sample Application: Read sno, sname and marks from end user (Persistence logic) calculate
total and average.
tot=m1+m2+m3
avg=tot/3 business logic
Generate rank for the student based his marks avg*(business logic)
Display student details
including tot, avg rank for end user…(Presentation logic).
End user: The operator of application is end user.
Note: If there is no separate business logic then persistent logic itself acts business logic of
application.
Java app----I/O Streams---------------------- Files
Java App-------JBDC, o-r mapping----------- Database Software.
Java App--------JDBC+OQL+ORDBMS----- ODB Software (Versant, Poet)
Files are good as persistent stores only in small scale applications like desktop games, mobile
games e.t.c., but there are not good as persistent stores in large scale projects. Database softwares
are good as persistent stores in medium, large scale organizations. EX: Banking websites e.t.c.,
Limitations of Files:
1. No security
2. No query language support
3. Update and delete operations are complex.
4. Manipulating data with multiple conditions is complex.
5. Merging and comparison.
To overcome this problem we use Database software as persistent stores.
Object Database Software: The Database software which can store software object as Database
table column value is called Object Database Software.

Wednesday, July 17, 2013

top indian websites which using ajax

top indian websites which using ajax
1.google maps
2.gmail
3.google serch
4.espn cric info
5.crick buzz
 

javascript code to retrive a value and text from a dropdown list

javascript code to retrive a value and text from a dropdown list

<script>
function GetSelectedItem()
{
    var z = document.getElementById("select1");
    var x = z.options[z.selectedIndex].value;
    var y = z.options[z.selectedIndex].text;
    alert("selected value is "+x);
    alert("selected text is "+y);

}
</script>

<div>
    <select id="select1">
        <option value="1">test1</option>
        <option value="2">test2</option>
        <option value="3">test3</option>
    </select>
    <br/>
    <button onClick="GetSelectedItem();">Get Selected Item</button>
</div>

Thursday, July 11, 2013

difference between == and === in javascript

1.== is equal to
2.=== is exactly equal to
== checks only the value
=== checks value as well as type
Given that x=5,
if x==8 it returns false
   x==5 it returns true
x==="5"  returns false
x===5 it returns true.

Monday, July 1, 2013

validation code in javascript for email validation

<script>
function validateForm()
{
var x=document.forms["register"]["email"].value;
var atpos=x.indexOf("@");
var space=x.indexOf(" ");
var dollar=x.indexOf("$");
var hash=x.indexOf("#");
var per=x.indexOf("%");
var or=x.indexOf("^");
var amber=x.indexOf("&");
var star=x.indexOf("*");
var plus=x.indexOf("+");
var minus=x.indexOf("-");
var coma=x.indexOf(",");
var dotpos=x.lastIndexOf(".");
var neg=x.indexOf("~");
var neq=x.indexOf("!");
var b1=x.indexOf(")");
var b2=x.indexOf("(");
var b3=x.indexOf(":");
var b5=x.indexOf("?");
var b6=x.indexOf(">");
var b7=x.indexOf("<");
var b8=x.indexOf("}");
var b9=x.indexOf("{");
var b10=x.indexOf("|");
if (x==null || x=="")
  {
  alert("Email is mandatory");
  return false;
  }
 
 if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length || space>0 || dollar>0 || hash>0 || per>0 || or>0 || amber>0 || star>0 || plus>0 || minus>0 || coma>0 || neg>0 || neq>0 || b1>0 || b2>0 || b3>0 || b5>0 || b6>0 || b7>0 || b8>0 || b9>0 || b10>0)
  {
  alert("Not a valid e-mail address");
  return false;
  }
  }
  </script>
<form name="register" onsubmit="return validateForm()" action='http:\\www.google.com' method='get'>
<font face="Times New Roaman">Email Address*</font></td><td><input type='text' name='email' value='example@domain.com' onblur="if (this.value == '') {this.value = 'example@domain.com';}"
 onfocus="if (this.value == 'example@domain.com') {this.value = '';}">
 <input type='submit' value='submit'>
</form>