CORE API / NOTES</>↗Core API29 Sep 2007
Previously for obtaining a MAC address we need to use a native code as a solution. In JDK 1.6 a new method is added in the java.net.NetworkInterface class, this method is getHardwareAddress(). package org.kodejava.net; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.net.UnknownHostException; public class MacAddress { public static void main(String[] args) { try { // […]
HIBERNATE / NOTES</>↗Hibernate28 Sep 2007
In this example we add the function to read a list of records in our LabelService class. This function will read all Label persistent object from database. You can see the other functions such as saveLabel, getLabel and deleteLabel in the related example section of this example. package org.kodejava.hibernate.service; import org.hibernate.Session; import org.kodejava.hibernate.SessionFactoryHelper; import org.kodejava.hibernate.model.Label; […]
HIBERNATE / NOTES</>↗Hibernate23 Sep 2007
Continuing the previous example How do I get object from database in Hibernate?, we now add the delete function in our LabelService class. package org.kodejava.hibernate.service; import org.hibernate.Session; import org.kodejava.hibernate.SessionFactoryHelper; import org.kodejava.hibernate.model.Label; public class LabelService { public Label getLabel(Long id) { Session session = SessionFactoryHelper.getSessionFactory().getCurrentSession(); session.beginTransaction(); // We g...
HIBERNATE / NOTES</>↗Hibernate19 Sep 2007
In the How do I store object in Hibernate? example you’ll see how tho store objects into database. In this example we’ll extend the LabelService class and add the capability to get or query object from database. package org.kodejava.hibernate.service; import org.hibernate.Session; import org.kodejava.hibernate.SessionFactoryHelper; import org.kodejava.hibernate.model.Label; public class LabelService { public Label getLabel(Long id) { Session […]
HIBERNATE / NOTES</>↗Hibernate16 Sep 2007
This example shows you how to store or save Hibernate object to database. The basic steps in creating application in Hibernate will be: Creates the POJO Create hibernate mapping file Register the mapping file in hibernate configuration Create a simple service class to store the object In this example we’ll create a class called Label, […]
HIBERNATE / NOTES</>↗Hibernate14 Sep 2007
When creating an application the use Hibernate to manage our application persistence object we’ll need a SessionFactory. This factory creates or open a session to talk to a database. To create a SessionFactory we can define the configuration in hibernate.properties, hibernate.cfg.xml or create it programmatically. In this example we’ll use the hibernate.cfg.xml configuration file, which […]