• No results found

Hibernate Tutorial

N/A
N/A
Protected

Academic year: 2021

Share "Hibernate Tutorial"

Copied!
149
0
0

Loading.... (view fulltext now)

Full text

(1)

Hibernate Tutorial - Hibernate 3 on Baby Steps

Posted by Dinesh Rajput

This hibernate tutorial provide step by step instructions on using Hibernate 3.0. Hibernate is popular open source object relational mapping tool for Java platform. It provides powerful, ultra-high performance object/relational persistence and query service for Java.

Actually Hibernate is much more than ORM Tool (Object - Relational Mapping) because today its provide lots of features in the persistence data layer.

ORM means Objects to Relational Mapping i.e. Java Persistence Objects are mapped to Relational databases by using ORM tools.

HIBERNATE : An ORM Tool

Used in the Data layer of the applications

Implements JPA (Java Persistence API) i.e its have set of standards that have been prescribed for any persistence of any implementation need to be satisfied to persistence rules in the java that given minimal change of codes means follow the all rules of persistence in later if any change in the ORM tools with minimum change in the code.

Why We Have to Use ORM Tools?

Here there is one problem to object save in to relational database each entity of the object save

individually to the database table in the associated columns. It is more times taken and complex in case of lots of user objects to be save into the database table.

(2)

When Inserting into database.

Object's Property ID set to ID column

Object's Property Name set to Name Column Object's Property Address set to Address Column Object's Property Phone set to Phone Column Object's Property Date of Birth set to DOB Column When Fetching Result Set from Database Table.

Column ID's Value set to Object's ID Property Column Name's Value set to Object's Name Property Column Address's Value set to Object's Address Property Column Phone's Value set to Object's Phone Property Column DOB's Value set to Object's Date of Birth Property

(3)

Hibernate Architecture : Chapter 2

Hibernate Architecture and API

(4)

Configuration: It represents a configuration or properties file for Hibernate. The

Configuration object is usually created once during application initialization. The

Configuration object reads and establishes the properties Hibernate uses to get

connected to a database and configure itself for work. A Configuration object is used to

create a SessionFactory and then typically is discarded.

SessionFactory :The SessionFactory is created from a Configuration object, and as its

name implies it is a factory for Session objects.The SessionFactory is an expensive

object to create. It, like the Configuration object, is usually created during application

start up. However, unlike the Configuration object, It should be created once and kept

for later use.

The SessionFactory object is used by all the threads of an application. It is a thread safe

object. One SessionFactory object is created per database. Multiple SessionFactory

objects (each requiring a separate onfiguration) are created when connecting to multiple

databases. The SessionFactory can also provide caching of persistent objects. -Dinesh

Session:Session objects provide the main interface to accomplish work with the

database. Persistent objects are saved and retrieved through a Session object. A

Session object is lightweight and inexpensive to create. A Session object does the work

of getting a physical connection to the database. Session objects maintain a cache for a

single application thread (request).

Session objects are not thread safe. Therefore, session objects should not be kept open

for a long time.Applications create and destroy these as needed. Typically, they are

created to complete a single unit of work, but may span many units. -Dinesh

Transaction: represents unit of works.

Query and Criteria

objects are used to retrieve (and recreate) persistent objects.

Setting Up Hibernate3 To Eclipse : Chapter 3

(5)

In this tutorial you will see how to configure Hibernate to Eclipse or STS or MyEclipse. 1. Download Eclipse Latest version and install in your machine.

2. Download Hibernate3 Latest Version. 3. Download MySQL database Latest version. 4. Download JConnector (MySQL Database Driver) Step 1 : Now open Eclipse you get following window-

(6)

Step 3: Click on Java Project you will get

(7)

Step 5:Right Click on Hibernate Project->go to Property ->Java Build Path->Library->Add Library

Step 6: Click on User Library ->Next->User Libraries..

on New window click on New a pop up of new window is open and fill User Library Name on the Text Field and Click on OK.

(8)

Step 7: Click on Add JARs.. go to specific path of the window where you are save Hibernate Zip file and add following required jar to your Application

 antlr-2.7.6  dom4j-1.6.1  hibernate3  hsqldb  javassist-3.4.GA  jta-1.1  slf4j-api-1.5.6  slf4j-simple-1.5.6  commons-collections-3.1

(9)

Finally you will get Hibernate Library in your application

(10)

Go to Project Property->Java Build Path->Library->Add External JARs..->Select Driver jar file->click finish

Now your application fully configured with all required libraries.

First Hibernate Application using Annotation :

Chapter 4

Lets we start on this topics. First we will see what is the process of using database without using Hibernate.

Saving Without Hibernate ->

 JDBC Database configuration  The Model Object

 Service method to create the model object  Database Design

 DAO method to use saving the model object to the database using SQL queries. With Hibernate Way->

 JDBC Database Configuration -> Hibernate Configuration  The Model Object -> Using Annotation

 Service method to create the model object -> Using the Hibernate API  Database Design -> Not Needed

 DAO method to use saving the model object to the database using SQL queries -> Not needed

Now as above steps of using hibernate, firstly we have to create Hibernate Configuration file. Step 1: File Name -> hibernate.cfg.xmlinsrcfolder of the application

(11)

Now we need to type all the detail related to MySQL database so we can use in our application. hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC

"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration>

<session-factory>

<!-- Database connection settings -->

<property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://localhost:3306/hibernateDB</property> <property name="connection.username">username</property> <property name="connection.password">password</property> <property name="connection.pool_size">1</property> <!-- SQL dialect --> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <!-- Enable Hibernate's automatic session context management -->

(12)

<property name="current_session_context_class">thread</property>

<!-- Disable the second-level cache -->

<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> <!-- Show all executed SQL to stdout -->

<property name="show_sql">true</property>

<!-- Drop and re-create the database schema on startup --> <property name="hbm2ddl.auto">create</property> <mapping class="com.sdnext.hibernate.tutorial.dto.UserDetails"/> </session-factory> </hibernate-configuration>

Herebelow property configure driver of the specific database

<property name="connection.driver_class">com.mysql.jdbc.Driver</property> Next line we configure the Database connection url

suppose we want to connect the database namehibernateDB

<property name="connection.url">jdbc:mysql://localhost:3306/hibernateDB</property> Next two lines set the user name and password of the connecting database hibernateDB <property name="connection.username">username</property>

<property name="connection.password">password</property>

Next line configure Dialect of the databaseMySQL, every database has its own Dialect.

What isDialect?means Dialect is configuration specify here so hibernate knows whats kind of language we are used and what type database we are used. we can say it is database dependent. It connects the database specific query language which we want to use.

<property name="dialect">org.hibernate.dialect.MySQLDialect</property>

The below line configured the model class name UserDetails its object we want save on the databasehibernateDB

<mapping class="com.sdnext.hibernate.tutorial.dto.UserDetails"/>

Now step 1 is over now we move to another step Now we have to create a Model class Step 2: UserDetails.java package com.sdnext.hibernate.tutorial.dto; import java.util.Date; import javax.persistence.Entity; import javax.persistence.Id; @Entity

public class UserDetails {

@Id

private int userId; private String userName; public int getUserId() { return userId; }

(13)

this.userId = userId; }

public String getUserName() { return userName;

}

public void setUserName(String userName) { this.userName = userName;

} }

Here @Entity means it telling hibernate this class treat as entity and need to save it the database. and @IDmeans it telling hibernate this property treat as primary key of the table.

these are two minimum required annotation we have use for saving the object in the database. Now we move to next step create service method to save the model object in the database. Using the Hibernate API

Create a session factory

create a session from the session factory

Use the session to save model objects Step 3: HibernateTestDemo.java package com.sdnext.hibernate.tutorial; import java.util.Date; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.AnnotationConfiguration; import com.sdnext.hibernate.tutorial.dto.UserDetails; public class HibernateTestDemo {

public static void main(String[] args) {

//Create the model object

UserDetails user = new UserDetails(); user.setUserId(1);

user.setUserName("Dinesh Rajput");

// Create Session Factory Object using Annotation Configuration

SessionFactory sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();

//Create Session object from session factory object Session session = sessionFactory.openSession(); session.beginTransaction();

//Use the session to save model objects session.save(user);

session.getTransaction().commit(); session.close();

} }

Now run application now we get a Tablewith name UserDetailsas its model class name with two columnsname are IDandUserNameas class propertyname.

(14)

Next Chapter we will write hibernate application using mapping file for the model class

First Hibernate Application Using Mapping File

: Chapter 5

In this chapter we will learn about how to use configuration file of the model class in stead of Annotation as used in the previous chapter and also learn about how to define model class property in the XML configuration fine or object mapping file(.hbm.xml).

As previous chapter we have write the model class UserDetalis.java package com.sdnext.hibernate.tutorial.dto;

public class UserDetails {

private int userId; private String userName; public int getUserId() { return userId; }

public void setUserId(int userId) { this.userId = userId;

}

public String getUserName() { return userName;

}

public void setUserName(String userName) { this.userName = userName;

} }

(15)

Mapping the UserDetalis Object to the Database UserDetails table

The file userdetails.hbm.xml is used to map userDetail Object to the UserDetails table in the database. Here is the code foruserdetails.hbm.xml:

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping>

<class name="com.sdnext.hibernate.tutorial.dto.UserDetails" table="UserDetails"> <id name="userId" type="long" column="ID" >

<generator class="assigned"/> </id> <property name="userName"> <column name="UserName" /> </property> </class> </hibernate-mapping>

Configuring Hibernate: here some change is required in the configuration file because we are used mapping file in stead of Annotation.

hibernate.cfg.xml:

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC

"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration>

<session-factory>

<!-- Database connection settings -->

<property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://localhost:3306/hibernateDB</property> <property name="connection.username">username</property> <property name="connection.password">password</property> <property name="connection.pool_size">1</property> <!-- SQL dialect --> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <!-- Enable Hibernate's automatic session context management -->

<property name="current_session_context_class">thread</property>

<!-- Disable the second-level cache -->

<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> <!-- Show all executed SQL to stdout -->

<property name="show_sql">true</property>

<!-- Drop and re-create the database schema on startup --> <property name="hbm2ddl.auto">create</property> <!-- Mapping files --> <mapping resource="userdetails.hbm.xml"/> </session-factory> </hibernate-configuration>

(16)

Here we are used mapping resource

<mapping resource="userdetails.hbm.xml"/>

in stead of mapping class.

<mapping class="com.sdnext.hibernate.tutorial.dto.UserDetails"/> Developing Code to Test Hibernate example:

Now there are three steps for using Hibernate API Create the session factory

Create the session object from the session factorySaving the model object using session object HibernateTestDemo.java package com.sdnext.hibernate.tutorial; import java.util.Date; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.AnnotationConfiguration; import com.sdnext.hibernate.tutorial.dto.UserDetails; public class HibernateTestDemo {

public static void main(String[] args) {

//Create the model object

UserDetails user = new UserDetails(); user.setUserId(1);

user.setUserName("Dinesh Rajput");

// Create Session Factory Object - using configuration object

SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();

//Create Session object from session factory object Session session = sessionFactory.openSession(); session.beginTransaction();

//Use the session to save model objects session.save(user);

session.getTransaction().commit(); session.close();

} }

Now you can run the application and see the result.

So in this topic we see how to use Mapping file to map the Model Object to relational database table.

In the Next Chapter We will Described the O/R Mapping file in details.

What is Hibernate O/R Mapping : Chapter 6

Hello Friends In Last chapters you learned about how to write our first hibernate application, there are two approach we have used for that---

(17)

2. Another way Using

Hibernate O/R Mapping file(.hbm.xml)

for Model Class Object Mapping.

In the last example we created

userDetails.hbm.xml

to map

UserDetails

Object to

the

UserDetails

table in the database. Now let's understand the each component of the mapping file. To recall here is the content of

userDetails.hbm.xml:

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping>

<class name="com.sdnext.hibernate.tutorial.dto.UserDetails" table="UserDetails"> <id name="userId" type="long" column="ID" >

<generator class="assigned"/> </id> <property name="userName"> <column name="UserName" /> </property> </class> </hibernate-mapping> 1.<hibernate-mapping> element:

The first or root element of hibernate mapping document is <hibernate-mapping> element. Between the <hibernate-mapping>tag class element(s) are present.

2.

<class> element:

The <Class> element maps the class object with corresponding entity in the database. It also tells what table in the database has to access and what column in that table it should use. Within one <hibernate-mapping> element, several <class> mappings are possible.

3.<id> element:

The <id> element in unique identifier to identify an object. In fact <id> element map with the primary key of the table. In our code :

<id name="userId" type="long" column="ID" >

primary key maps to the

ID

field of the table

UserDetails. Following is the attributes of <id> element

name- Property name of the persistence model class

type- The java data type used for that property

column- Name of the column for that property of the persistence object

unsaved-value -This is the value used to determine if a class has been made persistent. If the value of the id attribute is null, then it means that this object has not been persisted.

4.<generator> element:

Used to create primary key for new record, there are some commonly used generators type given below...  Increment-used to generate primary keys of type long, short or int that are unique only.

Sequence - used to generate primary keys for DB2, Oracle, SAP Database.

Assigned - is used when application code generates the primary key.

(18)

Identity -supports identity columns in DB2, MySQL, MS SQL Server, Sybase and HypersonicSQL. The returned identifier is of typelong,shortorint.

Uuid - Unique use ID of 128 bits generated from using algorithm and return type is String

hilo - generated by the hi/lo Algorithm

seqhilo - generated by the hi/lo Algorithm according to sequence of database  select -select from database triggered value

foreign -associated with the other model objects

5.<property> element: define standard Java attributes and their mapping into database schema. That is all about the mapping file for O/R mapping.I hope you was understand its all elements and its working in the hibernate.

Using Annotations in Hibernate vs

Configuration files : Chapter 8

ANNOTATIONS VS. XML

Since Java adopted annotations, I’ve heard a lot of discussion around whether to prefer annotations over external configuration files (often XML) and vice versa.

I think the decision boils down to two criteria: 1) Can annotations simplify the metadata?

2) Can changes to the metadata break behavior in your application?

If annotations do not reduce the amount of metadata that you have to provide (in most cases they do), then you shouldn’t use annotation.

For example, Hibernate mappings are often in XML, but annotations often provide the ability to specify the same mappings with significantly less metadata. Any changes you make to your mappings (whether in XML or annotations) could potentially be behavior breaking. You’re not going to change your mappings dynamically at run-time, are you? So, annotations seem like a much better choice.

[Note: I might consider using XML metadata for Hibernate when mapping to a legacy database because the annotations can often become bulky. Also, you are forced to use XML if you want to map the classes against two different databases with different schema. I haven't heard of a way to specify two mutually exclusive sets of Hibernate annotations on my classes. Even if this did exist it would be complex, which violates my first criterion for selecting annotations over XML.]

MAPPING:

 Mapping file is the heart of hibernate application.

 Every ORM tool needs this mapping, mapping is the mechanism of placing an object properties into column’s of a table.

(19)

 Mapping can be given to an ORM tool either in the form of an XML or in the form of the annotations.

 The mapping file contains mapping from a pojo class name to a table name and pojo class variable names to table column names.

 While writing an hibernate application, we can construct one or more mapping files, mean a hibernate application can contain any number of mapping files.

generally an object contains 3 properties like  Identity (Object Name)

 State (Object values)  Behavior (Object Methods)

But while storing an object into the database, we need to store only the values(State) right ? but how to avoid identity, behavior.. its not possible. In order to inform what value of an object has to be stored in what column of the table, will be taking care by the mapping, actually mapping can be done

using 2 ways,

 XML

 Annotations.

Actually annotations are introduced into java from JDK 1.5

Now we will look how to relate XML Mapping to Annotation

Mapping a class UserDetails to Table USER_DETAIL in XML --

<class name="com.sdnext.hibernate.tutorial.dto.UserDetails" table="USER_DETAIL">

Now Mapping a class UserDetails to Table USER_DETAIL in Annotation -- @Entity

@Table (name="USER_DETAIL") public class UserDetails{}

here @Entity declares the class as an entity (i.e. a persistent POJO class)

@Table is set at the class level; it allows you to define the table, catalog, and schema names for your entity mapping. If no@Table is defined the default values are used: the unqualified class name of the entity.

Mapping primary key USER_ID of table to property userId of class UserDetails in XML

<id name="userId" type="long" column="USER_ID" >

Mapping primary key USER_ID of table to property userId of class UserDetails in Annotation @Entity

@Table (name="USER_DETAILS") public class UserDetails

{ @Id

(20)

private long userId;

}

here @Id declares the identifier property of this entity. The class UserDetails is mapped to the USER_TABLE table, using the column USER_ID as its primary key column.

The column(s) used for a property mapping can be defined using the @Column annotation. Use it to override default values .

Id Generator Class Mapping in XML

<id name="userId" type="long" column="USER_ID" > <generator class="auto"/>

</id>

Id Generator Class Mapping in Annotation @Id

@Column(name="USER_ID")

@GeneratedValue(strategy=GenerationType.AUTO) private long userId;

Different GenerationType Enum Properties....

 AUTO - either identity column, sequence or table depending on the underlying DB  TABLE - table holding the id

 IDENTITY - identity column  SEQUENCE - sequence

 identity copy - the identity is copied from another entity

@GeneratedValue Provides for the specification of generation strategies for the values of primary keys. Enum GenerationType Defines the types of primary key generation strategies.

Mapping Column to the property of class in XML <property name="userName" column="USER_NAME">

Mapping Column to the property of class in Annotation

@Column(name="USER_NAME") private String userName;

@Column- provides the name of the column in a table if it is different from the attribute name. (By default, the two names are assumed to be the same.)

More JPA Annotations for Class Field:

@Basic - The use of the Basic annotation is optional for persistent fields and properties of these types. If the Basic annotation is not specified for such a field or property, the default values of

(21)

@Basic

private String userName;

@Transient - using when if you want skip any field of entity class to save in the database. Example- @Transient

private String middleName;

@Embedded- using when if property or field of persistence class is Embeddable persistence class. Example- class Address{ @Column(name="STREET")

@Embedded

private Address address;

@ElementColllection-Defines a collection of instances of a basic type or embeddable class. Must be specified if the collection is to be mapped by means of a collection table. Example-

@ElementCollection

private Collection<Address> lisOfAddresses = new ArrayList<Address>();

@Id-Specifies the primary key of an entity. Example-

@Id

private long userId;

@EmbeddedId-composite primary key of an embeddable class. Example-@Embeddable

Class Address{

@EmbeddedId

private int addressId;

}

@Version- Specifies the version field or property of an entity class that serves as its optimistic lock value. The version is used to ensure integrity when performing the merge operation and for optimistic

(22)

@Version

private int addressId;

@Temporal-This annotation must be specified for persistent fields or properties of type java.util.Date andjava.util.Calendar. Example-

@Column(name="JOIN_DATE") @Temporal(TemporalType.DATE) private Date joinDate;

Here we will learn about hbm2ddl Configuration in the hibernate configuration file (hibernate.cfg.xml). Actually hbm2ddl Configuration means hibernate mapping to create schema DDL (Data Definition Language).

<!-- Drop and re-create the database schema on startup --> <property name="hbm2ddl.auto">create</property>

Automatically validates or exports schema DDL to the database when the SessionFactory is created. With create-drop, the database schema will be dropped when the SessionFactory is closed explicitly.

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC

"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration>

<session-factory>

<!-- Database connection settings -->

<property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://localhost:3306/hibernateDB</property> <property name="connection.username">username</property> <property name="connection.password">password</property> <property name="connection.pool_size">1</property> <!-- SQL dialect --> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <!-- Enable Hibernate's automatic session context management -->

<property name="current_session_context_class">thread</property>

<!-- Disable the second-level cache -->

<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> <!-- Show all executed SQL to stdout -->

<property name="show_sql">true</property>

<!-- Drop and re-create the database schema on startup --> <property name="hbm2ddl.auto">create</property>

(23)

<!-- Mapping files --> <mapping resource="userdetails.hbm.xml"/> </session-factory> </hibernate-configuration>

Here <property name="hbm2ddl.auto">create</property> means schema DDL created every time when SessionFactory Object is created.

UserDetails.java package com.sdnext.hibernate.tutorial.dto; import javax.persistence.Entity; import javax.persistence.Column; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name="USER_TABLE") public class UserDetails

{ @Id

@Column(name="USER_ID") private int userId;

@Column(name="USER_NAME") private String userName;

public int getUserId() { return userId; }

public void setUserId(int userId) { this.userId = userId;

}

public String getUserName() { return userName;

}

public void setUserName(String userName) { this.userName = userName;

} }

Now we run this

example--public class HibernateTestDemo { public static void main(String[] args) {

//Create the model object

UserDetails user1 = new UserDetails(); UserDetails user2 = new UserDetails(); user1.setUserId(1);

user1.setUserName("Dinesh Rajput"); user2.setUserId(2);

(24)

// Create Session Factory Object - using annotation configuration object

SessionFactory sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();

//Create Session object from session factory object Session session = sessionFactory.openSession(); session.beginTransaction();

//Use the session to save model objects session.save(user1); session.save(user2); session.getTransaction().commit(); session.close(); } }

Run this example--

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version). log4j:WARN Please initialize the log4j system properly.

Hibernate: insert into USER_DETAILS ( USER_ID, USER_NAME) values (?, ?) Hibernate: insert into USER_DETAILS ( USER_ID, USER_NAME) values (?, ?) Now we get following table

structure--Again we running the following example-public class HibernateTestDemo { public static void main(String[] args) {

//Create the model object

UserDetails user1 = new UserDetails(); UserDetails user2 = new UserDetails(); user1.setUserId(3);

user1.setUserName("Dev Rajput"); user2.setUserId(4);

user2.setUserName("Sweety Rajput");

// Create Session Factory Object - using annotation configuration object

SessionFactory sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();

//Create Session object from session factory object Session session = sessionFactory.openSession(); session.beginTransaction();

//Use the session to save model objects session.save(user1);

(25)

session.getTransaction().commit(); session.close();

} }

Run this example--

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version). log4j:WARN Please initialize the log4j system properly.

Hibernate: insert into USER_DETAILS ( USER_ID, USER_NAME) values (?, ?) Hibernate: insert into USER_DETAILS ( USER_ID, USER_NAME) values (?, ?) Now we get the following table

schema--Here we see that the previous data is destroyed when we are using in the hibernate.cfg.xml file using the following line.

<property name="hbm2ddl.auto">create</property> Here

hbm2ddl.auto-->create -Always create new schema hbm2ddl.auto-->update -Update existing schema

Now we are replacing above line with the <property name="hbm2ddl.auto">update</property> public class HibernateTestDemo {

public static void main(String[] args) {

//Create the model object

UserDetails user1 = new UserDetails(); UserDetails user2 = new UserDetails(); user1.setUserId(1);

user1.setUserName("Dinesh Rajput"); user2.setUserId(2);

user2.setUserName("Anamika Rajput");

// Create Session Factory Object - using annotation configuration object

SessionFactory sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();

//Create Session object from session factory object Session session = sessionFactory.openSession(); session.beginTransaction();

//Use the session to save model objects session.save(user1); session.save(user2); session.getTransaction().commit(); session.close(); } }

(26)

Run this example--

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version). log4j:WARN Please initialize the log4j system properly.

Hibernate: insert into USER_DETAILS ( USER_ID, USER_NAME) values (?, ?) Hibernate: insert into USER_DETAILS ( USER_ID, USER_NAME) values (?, ?) Now we get the following table schema...

here we are looking the table USER_DETAILS only updated not again created.

Retrieving Objects in Hibernate using

session.get : Chapter 10

We'll look at one of the several ways we can fetch data from the database using Hibernate: the session.get method.

Now look following example... UserDetails.java package com.sdnext.hibernate.tutorial.dto; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table (name="USER_TABLE") public class UserDetails

{ @Id

@Column(name="USER_ID") private int userId;

@Column(name="USER_NAME") private String userName;

public void setUserId(int userId) { this.userId = userId;

}

public String getUserName() { return userName;

(27)

public void setUserName(String userName) { this.userName = userName;

}

public String toString() {

return "[User Name: "+userName+"User Id: "+userId+"]"; }

}

This is user domain persistence class UserDetails to store data into table USER_TABLE with columns name USER_ID and USER_NAME corresponding persisting field userId and userName respectively. Now we have to configure hibernate configuration file.

hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC

"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration>

<session-factory>

<!-- Database connection settings -->

<property name="connection.driver_class">com.mysql.jdbc.Driver</property>

<property name="connection.url">jdbc:mysql://localhost:3306/hibernateDB</property> <property name="connection.username">root</property>

<property name="connection.password">root</property> <!-- JDBC connection pool (use the built-in) -->

<property name="connection.pool_size">1</property> <!-- SQL dialect -->

<property name="dialect">org.hibernate.dialect.MySQLDialect</property> <!-- Enable Hibernate's automatic session context management -->

<property name="current_session_context_class">thread</property>

<!-- Disable the second-level cache -->

<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> <!-- Echo all executed SQL to stdout -->

<property name="show_sql">true</property>

<!-- Drop and re-create the database schema on startup --> <property name="hbm2ddl.auto">update</property>

<mapping class="com.sdnext.hibernate.tutorial.dto.UserDetails"/>

(28)

</session-factory> </hibernate-configuration>

here we are using MySql database hibernateDB. Now we running the code with following class file HibernateTestDemo.java package com.sdnext.hibernate.tutorial; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.AnnotationConfiguration; import com.sdnext.hibernate.tutorial.dto.UserDetails; public class HibernateTestDemo {

/**

* @param args */

public static void main(String[] args) {

UserDetails user = new UserDetails(); //Creating first user

user.setUserId(1);

user.setUserName("Dinesh Rajput");

UserDetails user2 = new UserDetails();//Creating second user

user2.setUserId(2);

user2.setUserName("Anamika Rajput");

SessionFactory sessionFactory = new

AnnotationConfiguration().configure().buildSessionFactory(); //Creating a session factory object

Session session = sessionFactory.openSession(); //Creating a session object for inserting users object to the database table USER_TABLE

session.beginTransaction(); //Open the transaction of session object to do something

session.save(user); //Inserting or Saving the first user

object session.save(user2); //Inserting or Saving the second user object

session.getTransaction().commit();//Close the transaction of session object after to do something

session.close(); //Close the session object performing saving event to database

user = null; //Now getting a user object from database table from session object

session = sessionFactory.openSession(); //Creating a new session object for fetching user object

session.beginTransaction(); //Again Open the transaction of the session object

user = (UserDetails) session.get(UserDetails.class, 1); //we get user object from session object using method session.get(Class arg1, Serializable arg2) here arg2 is primary key or id of the fetching object and arg1 is the what the model object we want to retrieve from database.

(29)

System.out.println(user); }

}

Here after running this code we get following output...

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version). log4j:WARN Please initialize the log4j system properly.

Hibernate: insert into USER_TABLE (USER_NAME, USER_ID) values (?, ?) Hibernate: insert into USER_TABLE (USER_NAME, USER_ID) values (?, ?)

Hibernate: select userdetail0_.USER_ID as USER1_0_0_, userdetail0_.USER_NAME as USER2_0_0_ from USER_TABLE userdetail0_ where userdetail0_.USER_ID=?

[User Name: Dinesh Rajput User Id: 1]

Hibernate Update Query : Chapter 11

In this tutorial we will show how to update a row with new information by retrieving data from the underlying database using the hibernate. Lets first write a java class to update a row to the database. Create a java class:

here we update the value of the field name userName with corresponding column name is USER_NAME in the database tableUSRE_TABLE.

In the above table we want to update the value of the USER_NAME column of the USER_TABLE table associated user model object which userId = 2

current value of the userName is 'Anamika Rajput' update to userName='Sweety'. Look the following class file.

HibernateTestDemo.java

package com.sdnext.hibernate.tutorial; import org.hibernate.Session;

(30)

import org.hibernate.SessionFactory;

import org.hibernate.cfg.AnnotationConfiguration; import com.sdnext.hibernate.tutorial.dto.UserDetails; public class HibernateTestDemo {

/**

* @param args */

public static void main(String[] args) {

UserDetails user = null;

SessionFactory sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory(); Session session = sessionFactory.openSession();

session.beginTransaction();

user = (UserDetails) session.get(UserDetails.class, 2); //Retrieving object which we want to update user.setUserName("Sweety"); //Set the updated userName to the model field

session.update(user); //Update to the database table session.getTransaction().commit();

System.out.println("Updated User ->"+user);

session.close(); }

} Output:

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version). log4j:WARN Please initialize the log4j system properly.

Hibernate: select userdetail0_.USER_ID as USER1_0_0_, userdetail0_.USER_NAME as USER2_0_0_ from USER_TABLE userdetail0_ where userdetail0_.USER_ID=?

Hibernate: update USER_TABLE set USER_NAME=? where USER_ID=? [Updated User -> User Name: Sweety User Id: 2]

(31)

We are looking the value of the USER_NAME column updated from 'Anamika Rajput' to 'Sweety' in the USER_TABLE table.

Hibernate Delete Query : Chapter 12

In this lesson we will show how to delete rows from the underlying database using the hibernate. Lets first write a java class to delete a row from the database.

Create a JAVA Class for this:

here we give the code of java class HibernateTestDemo.java which we will delete a row from the USER_TABLE table using the query "delete from USER_TABLE where USER_ID = 2"

Following is USER_TABLE:

package com.sdnext.hibernate.tutorial; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.AnnotationConfiguration; import com.sdnext.hibernate.tutorial.dto.UserDetails; public class HibernateTestDemo {

/**

* @param args */

public static void main(String[] args) {

SessionFactory sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory(); Session session = sessionFactory.openSession();

(32)

session.beginTransaction();

String sql = "DELETE FROM UserDetails WHERE USER_ID = 2"; Query query = session.createQuery(sql);

int row = query.executeUpdate(); if (row == 0)

System.out.println("Doesnt deleted any row!"); else

System.out.println("Deleted Row: " + row); session.getTransaction().commit();

session.close(); }

}

Output:

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version). log4j:WARN Please initialize the log4j system properly.

Hibernate: delete from USER_TABLE where USER_ID=2 Deleted Row: 1

Now we look the following table structure---

Value Types & Embedding Objects in

Hibernate : Chapter 13

(33)

We’ll learn the difference between Entity type objects and Value type objects. We’ll use the @Embeddable annotations to embed a value type object into our Entity class.

"An object of value type has no database identity; it belongs to an entity instance and its persistent state is embedded in the table row of the owning entity. Value types don't have identifiers or identifier properties"

Now In short we look the following points...

Object of Entity Type : has its own database identity

Object of Value Type : belongs to an entity, and its persistent state is embedded in the table row

of the owning entity. Value types don't have identifiers or identifier properties.

We look following example of Object of Entity Type: @Entity

@Table(name="USER_TABLE") public class UserDetails{

@Id @GeneratedValue(strategy=GenerationType.AUTO) @Column(name="USER_ID", type="INTEGER")

private long userId;

@Column(name="USER_NAME", type="String") private String userName;

@Column(name=USER_ADDRESS, type="String") private String address;

@Column(name="USER_PHONE", type="INTEGER") private long phone;

@Column(name="DOB", type="TIMESTAMP") private Date dob;

}

In Above table we saw that type of the all fields of the class USER CLASS have database entity type object.

ID is INTEGER type Name is VARCHAR type ADDRESS is VARCHAR type Phone is BIG INTEGER type DOB is TIMESTAMP type

All are the Entity Type Objects.

(34)

@Entity

@Table(name="USER_TABLE") public class UserDetails{

@Id @GeneratedValue(strategy=GenerationType.AUTO) @Column(name="USER_ID", type="INTEGER")

private long userId;

@Column(name="USER_NAME", type="String") private String userName;

@Column(name=USER_ADDRESS, type="??????") //What should be type for database private Address address;

@Column(name="USER_PHONE", type="INTEGER") private long phone;

@Column(name="DOB", type="TIMESTAMP") private Date dob;

}

Now lets see table structure for that...

here USER CLASS have a field Address type of the Value type object means in the database there are no meaning of Address type object.

Address type object have the four other fields like. 1. Street

(35)

3. State 4. Pin code

VALUE TYPE OBJECT APPROACH:>

Here there are one approach to save the value the Address Object save to the USER TABLE is the save the individually fields of this object to the separate columns of the USER TABLE. As following

This scenario is working in the hibernate only one condition is Address Object should be a Value Object (means there is no meaning to itself its provide the meaning to the entity object).

In this approach there are some problems are 1. Table complexity

2. Data Redundancy

3. User may have multiple Address like home address and office address etc. Look the above example in the code...

Address.java

package com.sdnext.hibernate.tutorial.dto; import javax.persistence.Column;

import javax.persistence.Embeddable;

@Embeddable //for value object it is not is entity object. Value object means does not have real

(36)

public class Address {

@Column(name="STREET_NAME") private String street;

@Column(name="CITY_NAME") private String city;

@Column(name="STATE_NAME") private String state;

@Column(name="PIN_CODE") private String pincode;

public String getStreet() { return street;

}

public void setStreet(String street) { this.street = street;

}

public String getCity() { return city;

}

public void setCity(String city) { this.city = city;

}

public String getState() { return state;

}

public void setState(String state) { this.state = state;

}

public String getPincode() { return pincode;

}

public void setPincode(String pincode) { this.pincode = pincode;

}

public String toString() {

return " {Street: "+street+" City: "+city+" State: "+state+" Pincode: "+pincode+" }"; }

}

@Embeddable: Target:

Classes

Defines a class whose instances are stored as an intrinsic part of an owning entity and share the identity of the entity. Each of the persistent properties or fields of the embedded object is mapped to the database table for the entity.

UserDetails.java package com.sdnext.hibernate.tutorial.dto; import java.util.Date; import javax.persistence.Column; import javax.persistence.Embedded; import javax.persistence.Entity;

(37)

import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table (name="USER_TABLE") public class UserDetails

{

@Id @GeneratedValue(strategy=GenerationType.AUTO) @Column(name="USER_ID")

private int userId;

@Column(name="USER_NAME") private String userName;

@Embedded //For value type object private Address address;

@Column(name="USER_PHONE") private String phone;

@Column(name="DOB") private Date dob;

public void setUserId(int userId) { this.userId = userId;

}

public String getUserName() { return userName;

}

public void setUserName(String userName) { this.userName = userName;

}

public Address getAddress() { return address;

}

public void setAddress(Address address) { this.address = address;

}

public String getPhone() { return phone;

}

public void setPhone(String phone) { this.phone = phone;

}

public Date getDob() { return dob;

}

public void setDob(Date dob) { this.dob = dob;

}

public int getUserId() { return userId; }

(38)

{

return "[User Name: "+userName+"User Id: "+userId+" User Address "+address+" Use phone " +phone+" ]";

} }

hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC

"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration>

<session-factory>

<!-- Database connection settings -->

<property name="connection.driver_class">com.mysql.jdbc.Driver</property>

<property name="connection.url">jdbc:mysql://localhost:3306/hibernateDB</property> <property name="connection.username">root</property>

<property name="connection.password">root</property> <!-- JDBC connection pool (use the built-in) -->

<property name="connection.pool_size">1</property> <!-- SQL dialect -->

<property name="dialect">org.hibernate.dialect.MySQLDialect</property> <!-- Enable Hibernate's automatic session context management -->

<property name="current_session_context_class">thread</property>

<!-- Disable the second-level cache -->

<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> <!-- Echo all executed SQL to stdout -->

<property name="show_sql">true</property>

<!-- Drop and re-create the database schema on startup --> <property name="hbm2ddl.auto">create</property> <mapping class="com.sdnext.hibernate.tutorial.dto.UserDetails"/> </session-factory> </hibernate-configuration> HibernateTestDemo.java package com.sdnext.hibernate.tutorial; import java.util.Date; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.AnnotationConfiguration; import com.sdnext.hibernate.tutorial.dto.Address; import com.sdnext.hibernate.tutorial.dto.UserDetails;

(39)

public class HibernateTestDemo { /**

* @param args */

public static void main(String[] args) {

UserDetails user1 = new UserDetails(); //create first user UserDetails user2 = new UserDetails(); //create second user

user1.setUserName("Dinesh Rajput"); user2.setUserName("Anamika Rajput");

Address address1 = new Address(); //create first value type object for entity type object user1 address1.setStreet("K Block House No. 403");

address1.setCity("Mangol Puri"); address1.setState("New Delhi"); address1.setPincode("110083"); user1.setAddress(address1);

Address address2 = new Address();//create second value type object for entity type object user2 address2.setStreet("Film City"); address2.setCity("Noida"); address2.setState("UP"); address2.setPincode("201301"); user2.setAddress(address2); user1.setDob(new Date()); user1.setPhone("+91-9953423462"); user2.setDob(new Date()); user2.setPhone("+91-9973423462");

SessionFactory sessionFactory = new

AnnotationConfiguration().configure().buildSessionFactory(); //create a session factory object Session session = sessionFactory.openSession(); // create session object from session factory session.beginTransaction(); //begin transaction for this session

session.save(user1); //save the first user session.save(user2); //save the second user

session.getTransaction().commit(); //commit the transaction the session session.close(); //close the session

} }

OUTPUT:

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version). log4j:WARN Please initialize the log4j system properly.

Hibernate: insert into USER_TABLE (CITY_NAME, PIN_CODE, STATE_NAME, STREET_NAME, DOB, USER_PHONE, USER_NAME) values (?, ?, ?, ?, ?, ?, ?)

Hibernate: insert into USER_TABLE (CITY_NAME, PIN_CODE, STATE_NAME, STREET_NAME, DOB, USER_PHONE, USER_NAME) values (?, ?, ?, ?, ?, ?, ?)

(40)

Attributes Override:

Here we have seen that an Entity Type Object USER has a Value Type Object(or Embeddable Object ) ADDRESS with corresponding fields name street, city, pin-code and state save to the database table USER_TABLE with value type object's column name (CITY_NAME, PIN_CODE, STATE_NAME, STREET_NAME).

But here some problems, suppose this user object have two types of addresses as like Local Address and Permanent Address then how to manage the column names of these value type objects in the database table USER_TABLE.

To overcome this problem we have to override the Attributes of the Value type objects. Lets see how to get in the code...

UserDetails.java package com.sdnext.hibernate.tutorial.dto; import java.util.Date; import javax.persistence.AttributeOverride; import javax.persistence.AttributeOverrides; import javax.persistence.Column; import javax.persistence.Embedded; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Lob; import javax.persistence.Table; @Entity

@Table (name="USER_TABLE")public class UserDetails {

@Id

@Column(name="USER_ID")

@GeneratedValue(strategy=GenerationType.AUTO) private int userId;

(41)

private String userName;

@Column(name="DOB") private Date joinDate; @Column(name="ADDRESS") @Embedded @AttributeOverrides({ @AttributeOverride(name="street", column=@Column(name="HOME_STREET_NAME")), @AttributeOverride(name="city", column=@Column(name="HOME_CITY_NAME")), @AttributeOverride(name="state", column=@Column(name="HOME_STATE_NAME")), @AttributeOverride(name="pincode", column=@Column(name="HOME_PIN_CODE"))}) private Address homeAddress;

@Embedded

private Address permanentAddress;

@Column(name="Phone") private String phone;

public int getUserId() { return userId; }

public Address getHomeAddress() { return homeAddress;

}

public void setHomeAddress(Address homeAddress) { this.homeAddress = homeAddress;

}

public void setUserId(int userId) { this.userId = userId;

}

public String getUserName() { return userName;

}

public void setUserName(String userName) { this.userName = userName;

}

public Date getDob() { return dob;

}

public void setDob(Date dob) { this.dob= dob;

}

public Address getPermanentAddress() { return permanentAaddress;

}

public void setPermanentAddress(Address permanentAddress) { this.permanentAddress = permanentAddress;

}

public String getPhone() { return phone;

}

public void setPhone(String phone) { this.phone= phone;

(42)

public String toString() {

return "[User Name: "+userName+"\n Permanent Address: "+permanentAddress+"\n Home Address: "+homeAddress+"\n Date of Birth: "+dob+"\n Phone: "+phone+"]";

} }

Now run the following code of the class file.. HibernateTestDemo.java package com.sdnext.hibernate.tutorial; import java.util.Date; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.AnnotationConfiguration; import com.sdnext.hibernate.tutorial.dto.Address; import com.sdnext.hibernate.tutorial.dto.UserDetails;

public class HibernateTestDemo { /**

* @param args */

public static void main(String[] args) {

UserDetails user = new UserDetails(); //create an user is entity type object //user.setUserId(1);

user.setUserName("Dinesh Rajput");

Address address = new Address(); //create an value type object of address class for home address address.setStreet("Block House No");

address.setCity("MangolaPuri"); address.setState("New Delhi"); address.setPincode("110089");

user.setHomeAddress(address); //set the home address

Address address1 = new Address();//create another value type object for the permanent address address1.setStreet("Film City");

address1.setCity("Noida"); address1.setState("UP"); address1.setPincode("201301");

user.setPermanentAddress(address1);//set the permanent address

user.setDob(new Date()); user.setPhone("9999222211");

SessionFactory sessionFactory = new

AnnotationConfiguration().configure().buildSessionFactory(); //create a session factory object Session session = sessionFactory.openSession(); //create a session object

session.beginTransaction(); //transaction object start

(43)

session.getTransaction().commit(); //commit the transaction object session.close(); //close the session

} }

After running the above code we will get the following table structure...

Saving Collections in Hibernate : Chapter 14

Now we’ll learn about the Collection in the hibernate.

In previous chapter we learned about Embedding value type object.

Now what will be do when there are a lots of embeddable objects instead of the single embeddable objects, In previous we have used two embeddable objects in the UserDetails class.

Suppose we want to keep tracks all addresses of an user, so think about one minute how to get. Lets we will using the Collection for that.

1. In this code snip User has one address class UserDetails{

---

private int userId; ---

private Address address; ---

}

2. In this code snip User has two addresses class UserDetails{

---

private int userId; ---

(44)

private Address address1; private Address address2; ---

}

3. In this code snip User has more than two addresses class UserDetails{

---

private int userId; ---

private Address address1; private Address address2; ---

private Address addressN; ---

}

In third case how to manage the records about addresses for that user, now for managing this type of problems we have to use the collection, we do not need to care about how many of the addresses user have. Lets see there are same change in the code for that...

class UserDetails{ ---

private int userId; ---

private List<Address> addresses = new ArrayList<Address>(); ---

(45)

Hibernate provides the facility to persist the collections. A collection can be a list, set, map, collection, sorted set, sorted map. java.util.List, java.util.Set, java.util.Collection, java.util.SortedSet,

java.util.SortedMap etc. are the real interface types to declared the persistent collection-value fields. Hibernate injects the persistent collections based on the type of interface. The collection instances usually behave likes the types of value behavior. Instances of collections are auto persisted if a persistent object refers it and are deleted automatically if it is not referred through. Elements of collection may shift from one table to another when a persistent object passed the collection to another persistent object.

We look following example of Object of Entity Type: @Entity

@Table(name="TBL_USER_DETAILS") public class UserDetails{

@Id

@Column(name="USER_ID", type="INTEGER") @GeneratedValue(strategy=GenerationType.AUTO) private long userId;

@Column(name="USER_NAME", type="String") private String userName;

@ElementCollection

private Collection<Address> lisOfAddresses = new ArrayList<Address>(); public Collection<Address> getLisOfAddresses() {

return lisOfAddresses; }

public void setLisOfAddresses(Collection<Address> lisOfAddresses) { this.lisOfAddresses = lisOfAddresses;

}

public int getUserId() { return userId; }

public void setUserId(int userId) { this.userId = userId;

}

public String getUserName() { return userName;

}

public void setUserName(String userName) { this.userName = userName;

}

public String toString() {

(46)

} }

@ElementCollection: Target:

Fields (including property get methods)

Defines a collection of instances of a basic type or embeddable class. Must be specified if the collection is to be mapped by means of a collection table.

Address.java

package com.sdnext.hibernate.tutorial.dto; import javax.persistence.Column;

import javax.persistence.Embeddable;

@Embeddable //for value object it is not is entity object. Value object means does not have real meaning for self individually.

public class Address {

@Column(name="STREET_NAME") private String street;

@Column(name="CITY_NAME") private String city;

@Column(name="STATE_NAME") private String state;

@Column(name="PIN_CODE") private String pincode;

public String getStreet() { return street;

}

public void setStreet(String street) { this.street = street;

}

public String getCity() { return city;

}

public void setCity(String city) { this.city = city;

}

public String getState() { return state;

References

Related documents

Institutional Distance Proposal was accepted to attend paper development workshop SMS special conference held in Guangzhou, China, Dec 14, 2012. Management Research Forum: China

The case study ‘Bajaj Auto: Evaluating Working Capital Requirement’ deals with the need and importance of investing in current assets and its implication on company’s

Vertebral corpectomy (vertebral body resection), partial or complete, anterior approach with decompression of spinal cord and/or nerve root(s); cervical, each additional segment

This paper (1) develops an empirically testable theoretical prediction that expected returns are impacted by heterogeneous beliefs; (2) uses a factor structure to

Name:    _____________________________________________  Address:   _____________________________________________  

Solving and Dissolving Musical Affection: A Critical Study of Spotify and Automated Music Recommendation in the 21st Century.. A dissertation submitted in partial satisfaction of

Separate records (individual controlled substance record) need to be maintained on all Schedule II drugs in the form of a declining inventory. Pharmacy will provide these

Spatial variability of soil hydraulics is a study of determining representative infiltration rate parameters for use in modeling infiltration characteristics of soil under