Wednesday, November 7, 2012
JPA vs Hibernate
Many enterprise Java developers use lightweight persistent objects provided by open-source frameworks or Data Access Objects instead of entity beans: entity beans and enterprise beans had a reputation of being too heavyweight and complicated, and one could only use them in Java EE application servers. Many of the features of the third-party persistence frameworks were incorporated into the Java Persistence API, and as of 2006 projects like Hibernate (version 3.2) and Open-Source Version TopLink Essentials have become implementations of the Java Persistence API.
JPA is really a specification
Hibernate provides an implementation of the JPA specification. Vendors providing EJB3.0 containers will also be providing an implementation of the JPA spec, so that means Sun and IBM WebSphere and Oracle and all the other handsome players in the industry will provide an implementatio
http://www.coderanch.com/t/218819/ORM/databases/Hibernate-vs-JPA
What is JPA?
JPA is a framework for managing relational data for Java. It can be used with applications utilizing JSE (Java Platform, Standard Edition) or JEE (Java Platform, Enterprise Edition). Its current version is JPA 2.0, which was released on 10 Dec, 2009. JPA replaced EJB 2.0 and EJB 1.1 entity beans (which were heavily criticized for being heavyweight by the Java developer community). Although entity beans (in EJB) provided persistence objects, many developers were used to utilizing relatively lightweight objects offered by DAO (Data Access Objects) and other similar frameworks instead. As a result, JPA was introduced, and it captured many of the neat features of the frameworks mentioned above
What is Hibernate?
Hibernate is a framework that can be used for object-relational mapping intended for Java programming language. More specifically, it is an ORM (object-relational mapping) library that can be used to map object-relational model in to conventional relational model. In simple terms, it creates a mapping between Java classes and tables in relational databases, also between Java to SQL data types. Hibernate can also be used for data querying and retrieving by generating SQL calls. Therefore, the programmer is relieved from the manual handling of result sets and converting objects. Hibernate is released as a free and open source framework distributed under GNU license. An implementation for JPA API is provided in Hibernate 3.2 and later versions.
What is the difference between JPA and Hibernate?
JPA is a framework for managing relational data in Java applications, while Hibernate is a specific implementation of JPA (so ideally, JPA and Hibernate cannot be directly compared). In other words, Hibernate is one of the most popular frameworks that implements JPA. Hibernate implements JPA through Hibernate Annotation and EntityManager libraries that are implemented on top of Hibernate Core libraries. Both EntityManager and Annotations follow the lifecycle of Hibernate. The newest JPA version (JPA 2.0) is fully supported by Hibernate 3.5. JPA has the benefit of having an interface that is standardized, so the developer community will be more familiar with it than Hibernate. On the other hand, native Hibernate APIs can be considered more powerful because its features are a superset of that of JPA.
http://www.differencebetween.com/difference-between-jpa-and-vs-hibernate/#ixzz2BXu2zE00
Labels:
java interview questions
Statement vs Prepared Statement
- Statement vs Prepared Statement
A prepared statement performs the following checks:
Makes sure that the tables and columns exist
Makes sure that the parameter types match their columns
Parses the SQL to make sure that the syntax is correct
Compiles and caches the compiled SQL so it can be re-executed without repeating these steps
http://stackoverflow.com/questions/8959036/statement-vs-prepared-statement-in-terms-of-precompilation
- The prepared statement concept is not specific to Java, it is a database concept. Statement precompiling means: when you execute a SQL query, database server will prepare a execution plan before executing the actual query, this execution plan will be cached at database server for further execution.
The advantages of Prepared Statements are:
As the execution plan get cached, performance will be better.
It is a good way to code against SQL Injection as escapes the input values.
When it comes to a Statement with no unbound variables, the database is free to optimize to its full extent. The individual query will be faster, but the down side is that you need to do the database compilation all the time, and this is worse than the benefit of the faster query.
http://webmoli.com/2008/10/23/back-to-basics-statement-vs-prepared-statement/
Labels:
java interview questions
ls command howto
Output from
picard@spnode15$
total 1600
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
picard@spnode15$
Let's look at this
File Type. The first position/character in this column describes what type of entry each horizontal line represents. The first character will usually be
-
= Regular File
d
= Directory
You can tell, just by looking at the output from
Permissions. The rest of the first column (after the
Directory Entries (and Hard-Link Count). The next column (immediately to the right of the access permissions) is a number which tells how many directory entries are under that item. For a regular file, this will typically be 1. For a directory, this will always be at least 2. The reason for this is that every directory always contains pointers to both itself, and its parent directory. You can see these two entries as the first two items in our example listing in Figure 12: the entries for
Owner. The next column to the right displays the
Group. The next column (mostly "STAFF" in our example) shows the name of the user group
Size. The next column shows the file size in bytes (characters).
Date/Time. The next 3 columns show the date and time the file was last
File Name. Finally, we have the file name. As discussed earlier, UNIX is very accommodating
http://docweb.cns.ufl.edu/docs/d0107/ar07s04.html
- Link counter
Most file systems that support hard links use reference counting.
On POSIX-compliant operating systems, such as
- Link count: File vs Directory
One
1. What is the link count of a file?
The link count of a file tells the total number of links a file has
The soft-link is not part of the link count since the soft-link's
2. How to find the link count of a file or directory?
any new file created will have a link count 1.
By default, a file will have a link count of 1
$ touch test.c
$ ln test.c test-
$
total 8
3145743
3145730
3145744 -
3145744 -
$ ln -s test.c test-
$
total 8
3145743
3145730
3145744 -
3145744 -
3145745
3. Does the link count decrease whenever the hard-link
When the hard link file
$
$
total 8
3145743
3145730
3145744 -
3145745
4. When does the link count of a directory change?
A directory "
link count of a directory minus 2 gives you the total number of sub-directories present in the directory.
$
$
$
$
$
3145746
http://www.theunixschool.com/2012/10/link-count-file-vs-directory.html
- Q1: The Unix
inode structure contains a reference count. What is the reference count for? Why can't wejust remove theinode without checking the reference count when a fileis deleted ?
- On a storage device,
a file or directory is contained in a collection of blocks
https://developer.ibm.com/tutorials/l-lpic1-104-6/
Labels:
linux
Subscribe to:
Posts (Atom)