This essay developed out of conversations I've had with several other programmers about why Java smelled suspicious. It's not a critique of Java!
Sycorax - complete tutorials
Programming Tutorials
" Java provides the industry - software companies and customer alike , an opportunity to create a true open computing environment where software is portable,
and customers benefit from increase competition. "
Java and the Future
December 1, 2008-LEJB 3.1: EJB New and Improved!
The EJB 3.0 specification was a huge improvement from what you were used to in the early versions of EJB. Available as an early draft, EJB 3.1 has many more features and is even easier to use.
December 1, 2008-Should Java Assert that Network I/O Can't Occur on the UI Thread?
Doing network I/O on the user interface (UI) thread is bad. Most developers know that and can tell you why; unfortunately, it's still done.
Register now to recieve special alert and latest technology news!
Mapping files are the heart of O/R mapping tools. These are the files that contain field to field mapping between the class attributes and the database columns.
Let's write a mapping file for the User class that we want to persist to the database.
<?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.sycorax.hibernate.User" table="USER" >
<id name="userId" type="java.lang.Long" column="user_id" >
<generator class="increment" />
</id>
<property name="firstName" type="java.lang.String" column="first_name" length="20" />
<property name="lastName" type="java.lang.String" column="last_name" length="20" />
<property name="age" type="java.lang.Integer" column="age" length="-1" />
<property name="email" type="java.lang.String" column="email" length="40" />
</class>
</hibernate-mapping>
As you can see,we have mapped all of the attributes of the class "User" to the columns of the table we created previously. Note the "id" attribute which maps the userId field of class User is defined in a different way than the other properties. The id tag is used to indicate that this is a primary key,and a <generator> tag is used to generate the primary key using different techniques. We have used the increment class,but there are also available different classes to support different kind of key generation techniques like generating key from a sequence,selecting from database etc. We can also use a custom key generator class.
Let us now add the mapping file to the Hibernate configuration file hibernate.cfg.xml. After adding the mapping resource entry,the hibernate.cfg.xml looks like this.