G l a r i m y TeachCode Series. Hibernate. Illustrated. Krishna Mohan Koyya

Size: px
Start display at page:

Download "G l a r i m y TeachCode Series. Hibernate. Illustrated. Krishna Mohan Koyya"

Transcription

1 G l a r i m y TeachCode Series Hibernate Illustrated Krishna Mohan Koyya

2 Basic Mapping Entities with XML Person.java import java.util.date; public class Person { private int id; private String name; private int phone; private Date dob; private boolean indian; private double height; private String profile; public int getid() { return id; public void setid(int id) { this.id = id; public String getname() { return name; public void setname(string name) { this.name = name; public int getphone() { return phone; public void setphone(int phone) { this.phone = phone; public Date getdob() { return dob; public void setdob(date dob) { this.dob = dob;

3 public boolean isindian() { return indian; public void setindian(boolean indian) { this.indian = indian; public double getheight() { return height; public void setheight(double height) { this.height = height; public String getprofile() { return profile; public void setprofile(string profile) { this.profile = public String tostring() { return "Person [id=" + id + ", name=" + name + ", dob=" + dob + ", indian=" + indian + ", height=" + height + ", phone=" + phone + ", profile=" + profile + "]"; HBMFirstApp.java import java.util.date; import org.hibernate.session; import org.hibernate.sessionfactory; import org.hibernate.transaction; import org.hibernate.cfg.configuration; public class HBMFirstApp { public static void main(string[] args) { Person swapnika = new Person(); swapnika.setname("swapnika");

4 swapnika.setdob(new Date(7, 26, 2008)); swapnika.setindian(true); swapnika.setphone( ); swapnika.setheight(5.6); swapnika.setprofile("senior Software Engineering working at Bangalore"); Person krishna = new Person(); krishna.setname("krishna"); krishna.setdob(new Date(7, 22, 1972)); krishna.setindian(true); krishna.setphone( ); krishna.setheight(5.8); krishna.setprofile("principle Consultant at Glarimy Technology Services"); SessionFactory factory = new Configuration().configure().buildSessionFactory(); Session session = factory.opensession(); Transaction tx = session.begintransaction(); try { session.save(swapnika); session.save(krishna); Person friend = (Person) session.get(person.class.getname(), swapnika.getid()); tx.commit(); System.out.println(friend); catch (Exception e) { e.printstacktrace(); tx.rollback(); finally { tx = null; session.close(); hibernate.cfg.xml <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration SYSTEM " <hibernate-configuration> <session-factory> name="hibernate.connection.url">jdbc:mysql://localhost/hbm</property> name="hibernate.connection.driver_class">com.mysql.jdbc.driver</property>

5 name="hibernate.connection.username">root</property> name="hibernate.connection.password">admin</property> name="hibernate.hbm2ddl.auto">create-drop</property> name="dialect">org.hibernate.dialect.mysqldialect</property> <mapping resource="first.hbm.xml" /> </session-factory> </hibernate-configuration> first.hbm.xml <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" " <hibernate-mapping package="com.glarimy.hbm"> <class name="person" table="people"> <id name="id" type="int"> <generator class="native" /> </id> name="name" type="string" unique="true" /> name="dob" type="date" column="date_of_birth" /> name="height" type="double" precision="2" scale="2" /> name="indian" type="boolean" /> name="phone" type="int" length="12" not-null="false" /> </class> </hibernate-mapping>

6 Basic Mapping Entities with JPA Annotations Person.java import java.util.date; import javax.persistence.column; import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.id; import javax.persistence.temporal; import javax.persistence.temporaltype; import = "People") public class private int = true) private String = true) private int = private Date dob; private boolean = 2, scale = 2) private double private String profile; public int getid() { return id; public void setid(int id) { this.id = id; public String getname() {

7 return name; public void setname(string name) { this.name = name; public int getphone() { return phone; public void setphone(int phone) { this.phone = phone; public Date getdob() { return dob; public void setdob(date dob) { this.dob = dob; public boolean isindian() { return indian; public void setindian(boolean indian) { this.indian = indian; public double getheight() { return height; public void setheight(double height) { this.height = height; public String getprofile() { return profile; public void setprofile(string profile) { this.profile = public String tostring() { return "Person [id=" + id + ", name=" + name + ", dob=" + dob + ", indian=" + indian + ", height=" + height + ", phone="

8 + phone + ", profile=" + profile + "]"; HBMSecondApp.java import java.util.date; import org.hibernate.session; import org.hibernate.sessionfactory; import org.hibernate.transaction; import org.hibernate.cfg.annotationconfiguration; public class HBMSecondApp public static void main(string[] args) { Person swapnika = new Person(); swapnika.setname("swapnika"); swapnika.setdob(new Date(7, 26, 2008)); swapnika.setindian(true); swapnika.setphone( ); swapnika.setheight(5.6); swapnika.setprofile("senior Software Engineering working at Bangalore"); Person krishna = new Person(); krishna.setname("krishna"); krishna.setdob(new Date(7, 22, 1972)); krishna.setindian(true); krishna.setphone( ); krishna.setheight(5.8); krishna.setprofile("principle Consultant at Glarimy Technology Services"); SessionFactory factory = new AnnotationConfiguration().configure().buildSessionFactory(); Session session = factory.opensession(); Transaction tx = session.begintransaction(); try { session.save(swapnika); session.save(krishna); Person friend = (Person) session.get(person.class.getname(), swapnika.getid()); tx.commit(); System.out.println(friend);

9 catch (Exception e) { e.printstacktrace(); tx.rollback(); finally { tx = null; session.close(); hibernate.cfg.xml <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration SYSTEM " <hibernate-configuration> <session-factory> name="hibernate.connection.url">jdbc:mysql://localhost/hbm</property> name="hibernate.connection.driver_class">com.mysql.jdbc.driver</property> name="hibernate.connection.username">root</property> name="hibernate.connection.password">admin</property> name="hibernate.hbm2ddl.auto">create-drop</property> name="dialect">org.hibernate.dialect.mysqldialect</property> <mapping class="com.glarimy.hbm.person" /> </session-factory> </hibernate-configuration>

10 CRUD operations through Hibernate Person.java import javax.persistence.column; import javax.persistence.entity; import javax.persistence.generatedvalue; import = "People") public class private int = true) private String = true) private int phone; public int getid() { return id; public void setid(int id) { this.id = id; public String getname() { return name; public void setname(string name) { this.name = name; public int getphone() { return phone; public void setphone(int phone) { this.phone = public String tostring() {

11 return "Person [id=" + id + ", name=" + name + ", phone=" + phone + "]"; HBMThirdApp.java import java.util.scanner; import org.hibernate.session; import org.hibernate.sessionfactory; import org.hibernate.transaction; import org.hibernate.cfg.annotationconfiguration; public class HBMThirdApp { public static void main(string[] args) { Scanner scanner = new Scanner(System.in); Person krishna = new Person(); krishna.setname("krishna"); krishna.setphone( ); SessionFactory factory = new AnnotationConfiguration().configure().buildSessionFactory(); Session session = factory.opensession(); Transaction tx = null; try { tx = session.begintransaction(); session.save(krishna); tx.commit(); System.out.println(krishna); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); tx = session.begintransaction(); krishna.setphone( ); tx.commit(); System.out.println(krishna); System.out.println("Check the table, update the phone number and enter any character to continue..."); scanner.nextline(); tx = session.begintransaction();

12 session.refresh(krishna); tx.commit(); System.out.println(krishna); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); tx = session.begintransaction(); session.evict(krishna); tx.commit(); System.out.println(krishna); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); tx = session.begintransaction(); session.delete(krishna); tx.commit(); System.out.println(krishna); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); catch (Exception e) { e.printstacktrace(); if (tx!= null) tx.rollback(); finally { tx = null; session.close(); hibernate.cfg.xml <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration SYSTEM " <hibernate-configuration> <session-factory> name="hibernate.connection.url">jdbc:mysql://localhost/hbm</property> name="hibernate.connection.driver_class">com.mysql.jdbc.driver</property> name="hibernate.connection.username">root</property> name="hibernate.connection.password">admin</property>

13 name="hibernate.hbm2ddl.auto">create-drop</property> name="dialect">org.hibernate.dialect.mysqldialect</property> <mapping class="com.glarimy.hbm.person" /> </session-factory> </hibernate-configuration>

14 Mapping Compound Keys Name.java import java.io.serializable; public class Name implements Serializable { private static final long serialversionuid = L; private String firstname; private String lastname; public Name() { public Name(String firstname, String lastname) { super(); this.firstname = firstname; this.lastname = lastname; public String getfirstname() { return firstname; public void setfirstname(string firstname) { this.firstname = firstname; public String getlastname() { return lastname; public void setlastname(string lastname) { this.lastname = public int hashcode() { final int prime = 31; int result = 1; result = prime * result + ((firstname == null)? 0 : firstname.hashcode()); result = prime * result + ((lastname == null)? 0 : lastname.hashcode()); return result;

15 @Override public boolean equals(object obj) { if (this == obj) return true; if (obj == null) return false; if (getclass()!= obj.getclass()) return false; Name other = (Name) obj; if (firstname == null) { if (other.firstname!= null) return false; else if (!firstname.equals(other.firstname)) return false; if (lastname == null) { if (other.lastname!= null) return false; else if (!lastname.equals(other.lastname)) return false; return public String tostring() { return "Name [firstname=" + firstname + ", lastname=" + lastname + "]"; Person.java import javax.persistence.column; import javax.persistence.entity; import javax.persistence.id; import = = com.glarimy.hbm.name.class) public class Person private String private String = true) private int phone;

16 public String getfirstname() { return firstname; public void setfirstname(string firstname) { this.firstname = firstname; public String getlastname() { return lastname; public void setlastname(string lastname) { this.lastname = lastname; public int getphone() { return phone; public void setphone(int phone) { this.phone = public String tostring() { return "Person [firstname=" + firstname + ", lastname=" + lastname + ", phone=" + phone + "]"; HBMFourthApp.java import java.util.scanner; import org.hibernate.session; import org.hibernate.sessionfactory; import org.hibernate.transaction; import org.hibernate.cfg.annotationconfiguration; public class HBMFourthApp { public static void main(string[] args) { Scanner scanner = new Scanner(System.in); Person krishna = new Person(); krishna.setfirstname("krishna Mohan"); krishna.setlastname("koyya");

17 krishna.setphone( ); SessionFactory factory = new AnnotationConfiguration().configure().buildSessionFactory(); Session session = factory.opensession(); Transaction tx = null; try { tx = session.begintransaction(); session.save(krishna); tx.commit(); System.out.println(krishna); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); Person mohan = (Person) session.get(person.class.getname(), new Name("Krishna Mohan", "Koyya")); System.out.println(mohan); catch (Exception e) { e.printstacktrace(); if (tx!= null) tx.rollback(); finally { tx = null; session.close(); hibernate.cfg.xml <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration SYSTEM " <hibernate-configuration> <session-factory> name="hibernate.connection.url">jdbc:mysql://localhost/hbm</property> name="hibernate.connection.driver_class">com.mysql.jdbc.driver</property> name="hibernate.connection.username">root</property> name="hibernate.connection.password">admin</property> name="hibernate.hbm2ddl.auto">create-drop</property> name="dialect">org.hibernate.dialect.mysqldialect</property> <mapping class="com.glarimy.hbm.person" /> </session-factory> </hibernate-configuration>

18 Mapping Compound Keys with Embedded ID Name.java import java.io.serializable; import public class Name implements Serializable { private static final long serialversionuid = L; private String firstname; private String lastname; public Name() { public Name(String firstname, String lastname) { super(); this.firstname = firstname; this.lastname = lastname; public String getfirstname() { return firstname; public void setfirstname(string firstname) { this.firstname = firstname; public String getlastname() { return lastname; public void setlastname(string lastname) { this.lastname = public int hashcode() { final int prime = 31; int result = 1; result = prime * result + ((firstname == null)? 0 : firstname.hashcode()); result = prime * result

19 + ((lastname == null)? 0 : lastname.hashcode()); return public boolean equals(object obj) { if (this == obj) return true; if (obj == null) return false; if (getclass()!= obj.getclass()) return false; Name other = (Name) obj; if (firstname == null) { if (other.firstname!= null) return false; else if (!firstname.equals(other.firstname)) return false; if (lastname == null) { if (other.lastname!= null) return false; else if (!lastname.equals(other.lastname)) return false; return public String tostring() { return "Name [firstname=" + firstname + ", lastname=" + lastname + "]"; Person.java import javax.persistence.column; import javax.persistence.embeddedid; import = "People") public class Person private Name = true) private int phone; public Name getname() {

20 return name; public void setname(name name) { this.name = name; public int getphone() { return phone; public void setphone(int phone) { this.phone = public String tostring() { return "Person [name=" + name + ", phone=" + phone + "]"; HBMFifthApp.java import java.util.scanner; import org.hibernate.session; import org.hibernate.sessionfactory; import org.hibernate.transaction; import org.hibernate.cfg.annotationconfiguration; public class HBMFifthApp { public static void main(string[] args) { Scanner scanner = new Scanner(System.in); Person krishna = new Person(); krishna.setname(new Name("Krishna Mohan", "Koyya")); SessionFactory factory = new AnnotationConfiguration().configure().buildSessionFactory(); Session session = factory.opensession(); Transaction tx = null; try { tx = session.begintransaction(); session.save(krishna); tx.commit(); System.out.println(krishna); System.out

21 .println("check the table and enter any character to continue..."); scanner.nextline(); Person mohan = (Person) session.get(person.class.getname(), new Name("Krishna Mohan", "Koyya")); System.out.println(mohan); catch (Exception e) { e.printstacktrace(); if (tx!= null) tx.rollback(); finally { tx = null; session.close(); hibernate.cfg.xml <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration SYSTEM " <hibernate-configuration> <session-factory> name="hibernate.connection.url">jdbc:mysql://localhost/hbm</property> name="hibernate.connection.driver_class">com.mysql.jdbc.driver</property> name="hibernate.connection.username">root</property> name="hibernate.connection.password">admin</property> name="hibernate.hbm2ddl.auto">create-drop</property> name="dialect">org.hibernate.dialect.mysqldialect</property> <mapping class="com.glarimy.hbm.person" /> </session-factory> </hibernate-configuration>

22 Mapping Components Address.java import public class Address { private String city; private int pin; public String getcity() { return city; public void setcity(string city) { this.city = city; public int getpin() { return pin; public void setpin(int pin) { this.pin = public String tostring() { return "Address [city=" + city + ", pin=" + pin + "]"; Person.java import javax.persistence.column; import javax.persistence.embedded; import javax.persistence.entity; import javax.persistence.generatedvalue; import = "People") public class Person

23 @GeneratedValue private int = true) private String = true) private int private Address address; public int getid() { return id; public void setid(int id) { this.id = id; public String getname() { return name; public void setname(string name) { this.name = name; public int getphone() { return phone; public void setphone(int phone) { this.phone = phone; public Address getaddress() { return address; public void setaddress(address address) { this.address = public String tostring() { return "Person [id=" + id + ", name=" + name + ", phone=" + phone + ", address=" + address + "]"; HBMSixthApp.java

24 import java.util.scanner; import org.hibernate.session; import org.hibernate.sessionfactory; import org.hibernate.transaction; import org.hibernate.cfg.annotationconfiguration; public class HBMSixthApp { public static void main(string[] args) { Scanner scanner = new Scanner(System.in); Address address = new Address(); address.setcity("bangalore"); address.setpin(560016); Person krishna = new Person(); krishna.setname("krishna"); krishna.setaddress(address); SessionFactory factory = new AnnotationConfiguration().configure().buildSessionFactory(); Session session = factory.opensession(); Transaction tx = null; try { tx = session.begintransaction(); session.save(krishna); tx.commit(); System.out.println(krishna); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); Person mohan = (Person) session.get(person.class.getname(), krishna.getid()); System.out.println(mohan); catch (Exception e) { e.printstacktrace(); if (tx!= null) tx.rollback(); finally { tx = null; session.close();

25 hibernate.cfg.xml <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration SYSTEM " <hibernate-configuration> <session-factory> name="hibernate.connection.url">jdbc:mysql://localhost/hbm</property> name="hibernate.connection.driver_class">com.mysql.jdbc.driver</property> name="hibernate.connection.username">root</property> name="hibernate.connection.password">admin</property> name="hibernate.hbm2ddl.auto">create-drop</property> name="dialect">org.hibernate.dialect.mysqldialect</property> <mapping class="com.glarimy.hbm.person" /> </session-factory> </hibernate-configuration>

26 Mapping One To One Association Address.java import javax.persistence.entity; import javax.persistence.generatedvalue; import public class private int id; private String city; private int pin; public int getid() { return id; public void setid(int id) { this.id = id; public String getcity() { return city; public void setcity(string city) { this.city = city; public int getpin() { return pin; public void setpin(int pin) { this.pin = public String tostring() { return "Address [city=" + city + ", id=" + id + ", pin=" + pin + "]";

27 Person.java import javax.persistence.cascadetype; import javax.persistence.column; import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.id; import javax.persistence.joincolumn; import = "People") public class private int = true) private String = true) private int = = "address", referencedcolumnname = "id") private Address address; public int getid() { return id; public void setid(int id) { this.id = id; public String getname() { return name; public void setname(string name) { this.name = name; public int getphone() { return phone; public void setphone(int phone) { this.phone = phone;

28 public Address getaddress() { return address; public void setaddress(address address) { this.address = public String tostring() { return "Person [id=" + id + ", name=" + name + ", phone=" + phone + ", address=" + address + "]"; HBMSeventhApp.java import java.util.scanner; import org.hibernate.session; import org.hibernate.sessionfactory; import org.hibernate.transaction; import org.hibernate.cfg.annotationconfiguration; public class HBMSeventhApp { public static void main(string[] args) { Scanner scanner = new Scanner(System.in); Address address = new Address(); address.setcity("bangalore"); address.setpin(560016); Person krishna = new Person(); krishna.setname("krishna"); krishna.setaddress(address); SessionFactory factory = new AnnotationConfiguration().configure().buildSessionFactory(); Session session = factory.opensession(); Transaction tx = null; try { tx = session.begintransaction(); session.save(krishna); tx.commit();

29 System.out.println(krishna); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); tx = session.begintransaction(); address.setpin(560034); tx.commit(); System.out.println(krishna); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); catch (Exception e) { e.printstacktrace(); if (tx!= null) tx.rollback(); finally { tx = null; session.close(); hibernate.cfg.xml <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration SYSTEM " <hibernate-configuration> <session-factory> name="hibernate.connection.url">jdbc:mysql://localhost/hbm</property> name="hibernate.connection.driver_class">com.mysql.jdbc.driver</property> name="hibernate.connection.username">root</property> name="hibernate.connection.password">admin</property> name="hibernate.hbm2ddl.auto">create-drop</property> name="dialect">org.hibernate.dialect.mysqlinnodbdialect</property> <mapping class="com.glarimy.hbm.person" /> <mapping class="com.glarimy.hbm.address" /> </session-factory> </hibernate-configuration>

30 Mapping One To Many Association Address.java import javax.persistence.entity; import javax.persistence.generatedvalue; import public class private int id; private String city; private int pin; public int getid() { return id; public void setid(int id) { this.id = id; public String getcity() { return city; public void setcity(string city) { this.city = city; public int getpin() { return pin; public void setpin(int pin) { this.pin = public String tostring() { return "Address [city=" + city + ", id=" + id + ", pin=" + pin + "]";

31 Person.java import java.io.serializable; import java.util.list; import javax.persistence.cascadetype; import javax.persistence.entity; import javax.persistence.fetchtype; import javax.persistence.generatedvalue; import javax.persistence.id; import javax.persistence.joincolumn; import = "People") public class Person implements Serializable { private static final long serialversionuid private int id; private String = CascadeType.ALL, fetch = = "person", referencedcolumnname = "name") private List<Address> addresses; public int getid() { return id; public void setid(int id) { this.id = id; public String getname() { return name; public void setname(string name) { this.name = name; public List<Address> getaddresses() { return addresses; public void setaddresses(list<address> addresses) { this.addresses = addresses;

32 @Override public String tostring() { return "Person [id=" + id + ", name=" + name + ", addresses=" + addresses + "]"; HBMEighthApp.java import java.util.arraylist; import java.util.list; import java.util.scanner; import org.hibernate.session; import org.hibernate.sessionfactory; import org.hibernate.transaction; import org.hibernate.cfg.annotationconfiguration; public class HBMEighthApp { public static void main(string[] args) { Scanner scanner = new Scanner(System.in); Address current = new Address(); current.setcity("bangalore"); current.setpin(560016); Address permanent = new Address(); permanent.setcity("tadepalligudem"); permanent.setpin(534101); List<Address> addresses = new ArrayList<Address>(); addresses.add(current); addresses.add(permanent); Person person = null; Person krishna = new Person(); krishna.setname("krishna"); krishna.setaddresses(addresses); SessionFactory factory = new AnnotationConfiguration().configure().buildSessionFactory(); Session session = factory.opensession(); Transaction tx = null; try { tx = session.begintransaction(); session.save(krishna);

33 tx.commit(); System.out.println(krishna); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); tx = session.begintransaction(); current.setpin(560034); tx.commit(); System.out.println(krishna); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); tx = session.begintransaction(); krishna.getaddresses().remove(0); tx.commit(); System.out.println(krishna); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); tx = session.begintransaction(); krishna.getaddresses().remove(0); tx.commit(); System.out.println(krishna); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); session.evict(krishna); person = (Person) session.get(person.class.getname(), krishna.getid()); catch (Exception e) { e.printstacktrace(); if (tx!= null) tx.rollback(); finally { tx = null; session.close(); System.out.println(person); System.out.println("Check the table and enter any character to continue..."); scanner.nextline();

34 hibernate.cfg.xml <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration SYSTEM " <hibernate-configuration> <session-factory> name="hibernate.connection.url">jdbc:mysql://localhost/hbm</property> name="hibernate.connection.driver_class">com.mysql.jdbc.driver</property> name="hibernate.connection.username">root</property> name="hibernate.connection.password">admin</property> name="hibernate.hbm2ddl.auto">create-drop</property> name="dialect">org.hibernate.dialect.mysqlinnodbdialect</property> <mapping class="com.glarimy.hbm.person" /> <mapping class="com.glarimy.hbm.address" /> </session-factory> </hibernate-configuration>

35 Mapping Many To Many Association Address.java import javax.persistence.entity; import javax.persistence.generatedvalue; import public class private int id; private String city; private int pin; public int getid() { return id; public void setid(int id) { this.id = id; public String getcity() { return city; public void setcity(string city) { this.city = city; public int getpin() { return pin; public void setpin(int pin) { this.pin = public String tostring() { return "Address [city=" + city + ", id=" + id + ", pin=" + pin + "]";

36 Person.java import java.io.serializable; import java.util.arraylist; import java.util.list; import javax.persistence.cascadetype; import javax.persistence.entity; import javax.persistence.fetchtype; import javax.persistence.generatedvalue; import javax.persistence.id; import javax.persistence.jointable; import = "People") public class Person implements Serializable { private static final long serialversionuid private int id; private String private List<Address> addresses = new ArrayList<Address>(); public int getid() { return id; public void setid(int id) { this.id = id; public String getname() { return name; public void setname(string name) { this.name = name; public List<Address> getaddresses() { return addresses; public void setaddresses(list<address> addresses) {

37 this.addresses = public String tostring() { return "Person [id=" + id + ", name=" + name + ", addresses=" + addresses + "]"; HBMNinthApp.java import java.util.scanner; import org.hibernate.session; import org.hibernate.sessionfactory; import org.hibernate.transaction; import org.hibernate.cfg.annotationconfiguration; public class HBMNinthApp { public static void main(string[] args) { Scanner scanner = new Scanner(System.in); Address current = new Address(); current.setcity("bangalore"); current.setpin(560016); Address permanent = new Address(); permanent.setcity("tadepalligudem"); permanent.setpin(534101); Address office = new Address(); office.setcity("e-city"); office.setpin(560100); Person krishna = new Person(); krishna.setname("krishna"); krishna.getaddresses().add(current); krishna.getaddresses().add(permanent); Person swapnika = new Person(); swapnika.setname("swapnika"); swapnika.getaddresses().add(current); swapnika.getaddresses().add(permanent); swapnika.getaddresses().add(office); Person person = null;

38 SessionFactory factory = new AnnotationConfiguration().configure().buildSessionFactory(); Session session = factory.opensession(); Transaction tx = null; try { tx = session.begintransaction(); session.save(krishna); tx.commit(); System.out.println(krishna); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); tx = session.begintransaction(); session.save(swapnika); tx.commit(); System.out.println(swapnika); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); tx = session.begintransaction(); current.setpin(560034); tx.commit(); System.out.println(krishna); System.out.println(swapnika); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); tx = session.begintransaction(); krishna.getaddresses().remove(0); tx.commit(); System.out.println(krishna); System.out.println(swapnika); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); session.evict(krishna); person = (Person) session.get(person.class.getname(), krishna.getid()); catch (Exception e) { e.printstacktrace();

39 if (tx!= null) tx.rollback(); finally { tx = null; session.close(); System.out.println(person); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); hibernate.cfg.xml <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration SYSTEM " <hibernate-configuration> <session-factory> name="hibernate.connection.url">jdbc:mysql://localhost/hbm</property> name="hibernate.connection.driver_class">com.mysql.jdbc.driver</property> name="hibernate.connection.username">root</property> name="hibernate.connection.password">admin</property> name="hibernate.hbm2ddl.auto">create-drop</property> name="dialect">org.hibernate.dialect.mysqlinnodbdialect</property> <mapping class="com.glarimy.hbm.person" /> <mapping class="com.glarimy.hbm.address" /> </session-factory> </hibernate-configuration>

40 Mapping Bidirectional Associations Address.java import java.util.arraylist; import java.util.list; import javax.persistence.cascadetype; import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.id; import public class private int id; private String city; private int = CascadeType.ALL, mappedby = "addresses") private List<Person> persons = new ArrayList<Person>(); public int getid() { return id; public void setid(int id) { this.id = id; public String getcity() { return city; public void setcity(string city) { this.city = city; public int getpin() { return pin; public void setpin(int pin) { this.pin = pin;

41 public List<Person> getpersons() { return persons; public void setpersons(list<person> persons) { this.persons = public String tostring() { return "Address [id=" + id + ", city=" + city + ", pin=" + pin + "]"; Person.java import java.io.serializable; import java.util.arraylist; import java.util.list; import javax.persistence.cascadetype; import javax.persistence.entity; import javax.persistence.fetchtype; import javax.persistence.generatedvalue; import javax.persistence.id; import javax.persistence.joincolumn; import javax.persistence.jointable; import = "People") public class Person implements Serializable { private static final long serialversionuid private int id; private String name="people_addresses", joincolumns=@joincolumn(name="person", referencedcolumnname="id"), inversejoincolumns=@joincolumn(name="address", referencedcolumnname="id")) private List<Address> addresses = new ArrayList<Address>(); public int getid() {

42 return id; public void setid(int id) { this.id = id; public String getname() { return name; public void setname(string name) { this.name = name; public List<Address> getaddresses() { return addresses; public void setaddresses(list<address> addresses) { this.addresses = public String tostring() { return "Person [id=" + id + ", name=" + name + ", addresses=" + addresses + "]"; HBMTenthApp.java import java.util.scanner; import org.hibernate.session; import org.hibernate.sessionfactory; import org.hibernate.transaction; import org.hibernate.cfg.annotationconfiguration; public class HBMTenthApp { public static void main(string[] args) { Scanner scanner = new Scanner(System.in); Address current = new Address(); current.setcity("bangalore"); current.setpin(560016);

43 Address permanent = new Address(); permanent.setcity("tadepalligudem"); permanent.setpin(534101); Address office = new Address(); office.setcity("e-city"); office.setpin(560100); Person krishna = new Person(); krishna.setname("krishna"); current.getpersons().add(krishna); permanent.getpersons().add(krishna); krishna.getaddresses().add(current); krishna.getaddresses().add(permanent); Person swapnika = new Person(); swapnika.setname("swapnika"); current.getpersons().add(swapnika); permanent.getpersons().add(swapnika); office.getpersons().add(swapnika); swapnika.getaddresses().add(current); swapnika.getaddresses().add(permanent); swapnika.getaddresses().add(office); Person person = null; SessionFactory factory = new AnnotationConfiguration().configure().buildSessionFactory(); Session session = factory.opensession(); Transaction tx = null; try { tx = session.begintransaction(); session.save(krishna); tx.commit(); System.out.println(krishna); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); tx = session.begintransaction(); session.save(swapnika); tx.commit(); System.out.println(swapnika); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); tx = session.begintransaction();

44 current.setpin(560034); tx.commit(); System.out.println(krishna); System.out.println(swapnika); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); tx = session.begintransaction(); krishna.getaddresses().remove(0); tx.commit(); System.out.println(krishna); System.out.println(swapnika); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); session.evict(krishna); person = (Person) session.get(person.class.getname(), krishna.getid()); catch (Exception e) { e.printstacktrace(); if (tx!= null) tx.rollback(); finally { tx = null; session.close(); System.out.println(person); System.out.println("Check the table and enter any character to continue..."); scanner.nextline(); hibernate.cfg.xml <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration SYSTEM " <hibernate-configuration> <session-factory> name="hibernate.connection.url">jdbc:mysql://localhost/hbm</property>

45 name="hibernate.connection.driver_class">com.mysql.jdbc.driver</property> name="hibernate.connection.username">root</property> name="hibernate.connection.password">admin</property> name="hibernate.hbm2ddl.auto">create-drop</property> name="dialect">org.hibernate.dialect.mysqlinnodbdialect</property> <mapping class="com.glarimy.hbm.person" /> <mapping class="com.glarimy.hbm.address" /> </session-factory> </hibernate-configuration>

46 Mapping Inheritance Using Single Table Strategy Person.java import java.io.serializable; import javax.persistence.discriminatorcolumn; import javax.persistence.discriminatortype; import javax.persistence.discriminatorvalue; import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.id; import javax.persistence.inheritance; import public class Person implements Serializable { private static final long serialversionuid protected int id; protected String name; public int getid() { return id; public void setid(int id) { this.id = id; public String getname() { return name; public void setname(string name) { this.name = public String tostring() { return "Person [id=" + id + ", name=" + name + "]";

47 Employee.java import javax.persistence.discriminatorvalue; = "2") public class Employee extends Person { private static final long serialversionuid = L; private double salary; public void setsalary(double salary) { this.salary = public String tostring() { return "Employee [id=" + id + ", name=" + name + ", salary=" + salary + "]"; HBMEleventhApp.java import java.util.list; import org.hibernate.query; import org.hibernate.session; import org.hibernate.sessionfactory; import org.hibernate.transaction; import org.hibernate.cfg.annotationconfiguration; public class HBMEleventhApp public static void main(string[] args) { Person krishna = new Person(); krishna.setname("krishna"); Employee swapnika = new Employee(); swapnika.setname("swapnika"); swapnika.setsalary(30000);

48 SessionFactory factory = new AnnotationConfiguration().configure().buildSessionFactory(); Session session = factory.opensession(); Transaction tx = null; try { tx = session.begintransaction(); session.save(krishna); session.save(swapnika); Query query = session.createquery("from com.glarimy.hbm.person"); List<Person> persons = query.list(); for (Person p : persons) System.out.println(p); tx.commit(); catch (Exception e) { e.printstacktrace(); if (tx!= null) tx.rollback(); finally { tx = null; session.close(); hibernate.cfg.xml <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration SYSTEM " <hibernate-configuration> <session-factory> name="hibernate.connection.url">jdbc:mysql://localhost/hbm</property> name="hibernate.connection.driver_class">com.mysql.jdbc.driver</property> name="hibernate.connection.username">root</property> name="hibernate.connection.password">admin</property> name="hibernate.hbm2ddl.auto">create-drop</property> name="dialect">org.hibernate.dialect.mysqlinnodbdialect</property> <mapping class="com.glarimy.hbm.person" /> <mapping class="com.glarimy.hbm.employee" /> </session-factory> </hibernate-configuration>

49 Mapping Inheritance Using Table Per Class Strategy Person.java import java.io.serializable; import javax.persistence.entity; import javax.persistence.id; import javax.persistence.inheritance; import = public class Person implements Serializable { private static final long serialversionuid = protected int id; protected String name; public int getid() { return id; public void setid(int id) { this.id = id; public String getname() { return name; public void setname(string name) { this.name = public String tostring() { return "Person [id=" + id + ", name=" + name + "]"; Employee.java import javax.persistence.entity;

50 @Entity public class Employee extends Person { private static final long serialversionuid = L; private double salary; public void setsalary(double salary) { this.salary = public String tostring() { return "Employee [id=" + id + ", name=" + name + ", salary=" + salary + "]"; HBMTwelvthApp.java import java.util.list; import org.hibernate.query; import org.hibernate.session; import org.hibernate.sessionfactory; import org.hibernate.transaction; import org.hibernate.cfg.annotationconfiguration; public class HBMTwelvthApp public static void main(string[] args) { Person krishna = new Person(); krishna.setid(1); krishna.setname("krishna"); Employee swapnika = new Employee(); swapnika.setid(2); swapnika.setname("swapnika"); swapnika.setsalary(30000); SessionFactory factory = new AnnotationConfiguration().configure().buildSessionFactory(); Session session = factory.opensession(); Transaction tx = null; try { tx = session.begintransaction();

51 session.save(krishna); session.save(swapnika); Query query = session.createquery("from com.glarimy.hbm.person"); List<Person> persons = query.list(); for (Person p : persons) System.out.println(p); tx.commit(); catch (Exception e) { e.printstacktrace(); if (tx!= null) tx.rollback(); finally { tx = null; session.close(); hibernate.cfg.xml <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration SYSTEM " <hibernate-configuration> <session-factory> name="hibernate.connection.url">jdbc:mysql://localhost/hbm</property> name="hibernate.connection.driver_class">com.mysql.jdbc.driver</property> name="hibernate.connection.username">root</property> name="hibernate.connection.password">admin</property> name="hibernate.hbm2ddl.auto">create-drop</property> name="dialect">org.hibernate.dialect.mysqlinnodbdialect</property> <mapping class="com.glarimy.hbm.person" /> <mapping class="com.glarimy.hbm.employee" /> </session-factory> </hibernate-configuration>

52 Mapping Inheritance Using Join Table Strategy Person.java import java.io.serializable; import javax.persistence.entity; import javax.persistence.id; import javax.persistence.inheritance; import = = InheritanceType.JOINED) public class Person implements Serializable { private static final long serialversionuid = protected int id; protected String name; public int getid() { return id; public void setid(int id) { this.id = id; public String getname() { return name; public void setname(string name) { this.name = public String tostring() { return "Person [id=" + id + ", name=" + name + "]"; Employee.java import javax.persistence.entity;

53 @Entity public class Employee extends Person { private static final long serialversionuid = L; private double salary; public void setsalary(double salary) { this.salary = public String tostring() { return "Employee [id=" + id + ", name=" + name + ", salary=" + salary + "]"; HBMThirteenthApp.java import java.util.list; import org.hibernate.query; import org.hibernate.session; import org.hibernate.sessionfactory; import org.hibernate.transaction; import org.hibernate.cfg.annotationconfiguration; public class HBMThirteenthApp public static void main(string[] args) { Person krishna = new Person(); krishna.setid(1); krishna.setname("krishna"); Employee swapnika = new Employee(); swapnika.setid(2); swapnika.setname("swapnika"); swapnika.setsalary(30000); SessionFactory factory = new AnnotationConfiguration().configure().buildSessionFactory(); Session session = factory.opensession(); Transaction tx = null; try { tx = session.begintransaction(); session.save(krishna);

54 session.save(swapnika); Query query = session.createquery("from com.glarimy.hbm.person"); List<Person> persons = query.list(); for (Person p : persons) System.out.println(p); tx.commit(); catch (Exception e) { e.printstacktrace(); if (tx!= null) tx.rollback(); finally { tx = null; session.close(); hibernate.cfg.xml <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration SYSTEM " <hibernate-configuration> <session-factory> name="hibernate.connection.url">jdbc:mysql://localhost/hbm</property> name="hibernate.connection.driver_class">com.mysql.jdbc.driver</property> name="hibernate.connection.username">root</property> name="hibernate.connection.password">admin</property> name="hibernate.hbm2ddl.auto">create-drop</property> name="dialect">org.hibernate.dialect.mysqlinnodbdialect</property> <mapping class="com.glarimy.hbm.person" /> <mapping class="com.glarimy.hbm.employee" /> </session-factory> </hibernate-configuration>

55 Mapping a Non-Entity Super Class Person.java import java.io.serializable; import public class Person implements Serializable { private static final long serialversionuid = L; protected String name; public String getname() { return name; public void setname(string name) { this.name = public String tostring() { return "Person [name=" + name + "]"; Employee.java import javax.persistence.entity; import javax.persistence.generatedvalue; import public class Employee extends Person { private static final long serialversionuid private int id; private double salary; public void setsalary(double salary) { this.salary = salary;

56 @Override public String tostring() { return "Employee [id=" + id + ", name=" + name + ", salary=" + salary + "]"; HBMFourteenthApp.java import java.util.list; import org.hibernate.query; import org.hibernate.session; import org.hibernate.sessionfactory; import org.hibernate.transaction; import org.hibernate.cfg.annotationconfiguration; public class HBMFourteenthApp public static void main(string[] args) { Person krishna = new Person(); krishna.setname("krishna"); Employee swapnika = new Employee(); swapnika.setname("swapnika"); swapnika.setsalary(30000); SessionFactory factory = new AnnotationConfiguration().configure().buildSessionFactory(); Session session = factory.opensession(); Transaction tx = null; try { tx = session.begintransaction(); session.save(swapnika); Query query = session.createquery("from com.glarimy.hbm.person"); List<Person> persons = query.list(); for (Person p : persons) System.out.println(p); tx.commit(); catch (Exception e) { e.printstacktrace(); if (tx!= null)

57 tx.rollback(); finally { tx = null; session.close(); hibernate.cfg.xml <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration SYSTEM " <hibernate-configuration> <session-factory> name="hibernate.connection.url">jdbc:mysql://localhost/hbm</property> name="hibernate.connection.driver_class">com.mysql.jdbc.driver</property> name="hibernate.connection.username">root</property> name="hibernate.connection.password">admin</property> name="hibernate.hbm2ddl.auto">create-drop</property> name="dialect">org.hibernate.dialect.mysqlinnodbdialect</property> <mapping class="com.glarimy.hbm.employee" /> </session-factory> </hibernate-configuration>

HIBERNATE - COMPONENT MAPPINGS

HIBERNATE - COMPONENT MAPPINGS HIBERNATE - COMPONENT MAPPINGS http://www.tutorialspoint.com/hibernate/hibernate_component_mappings.htm Copyright tutorialspoint.com A Component mapping is a mapping for a class having a reference to another

More information

HIBERNATE - MANY-TO-ONE MAPPINGS

HIBERNATE - MANY-TO-ONE MAPPINGS HIBERNATE - MANY-TO-ONE MAPPINGS http://www.tutorialspoint.com/hibernate/hibernate_many_to_one_mapping.htm Copyright tutorialspoint.com A many-to-one association is the most common kind of association

More information

HIBERNATE - INTERCEPTORS

HIBERNATE - INTERCEPTORS HIBERNATE - INTERCEPTORS http://www.tutorialspoint.com/hibernate/hibernate_interceptors.htm Copyright tutorialspoint.com As you have learnt that in Hibernate, an object will be created and persisted. Once

More information

HIBERNATE - ONE-TO-ONE MAPPINGS

HIBERNATE - ONE-TO-ONE MAPPINGS HIBERNATE - ONE-TO-ONE MAPPINGS http://www.tutorialspoint.com/hibernate/hibernate_one_to_one_mapping.htm Copyright tutorialspoint.com A one-to-one association is similar to many-to-one association with

More information

Step By Step Guideline for Building & Running HelloWorld Hibernate Application

Step By Step Guideline for Building & Running HelloWorld Hibernate Application Step By Step Guideline for Building & Running HelloWorld Hibernate Application 1 What we are going to build A simple Hibernate application persisting Person objects The database table, person, has the

More information

HIBERNATE - SORTEDSET MAPPINGS

HIBERNATE - SORTEDSET MAPPINGS HIBERNATE - SORTEDSET MAPPINGS http://www.tutorialspoint.com/hibernate/hibernate_sortedset_mapping.htm Copyright tutorialspoint.com A SortedSet is a java collection that does not contain any duplicate

More information

Installing MySQL. Hibernate: Setup, Use, and Mapping file. Setup Hibernate in IDE. Starting WAMP server. phpmyadmin web console

Installing MySQL. Hibernate: Setup, Use, and Mapping file. Setup Hibernate in IDE. Starting WAMP server. phpmyadmin web console Installing MySQL Hibernate: Setup, Use, and Mapping file B.Tech. (IT), Sem-6, Applied Design Patterns and Application Frameworks (ADPAF) Dharmsinh Desai University Prof. H B Prajapati Way 1 Install from

More information

Unit 6 Hibernate. List the advantages of hibernate over JDBC

Unit 6 Hibernate. List the advantages of hibernate over JDBC Q1. What is Hibernate? List the advantages of hibernate over JDBC. Ans. Hibernate is used convert object data in JAVA to relational database tables. It is an open source Object-Relational Mapping (ORM)

More information

Chapter 3. Harnessing Hibernate

Chapter 3. Harnessing Hibernate Chapter 3. Harnessing Hibernate hibernate.cfg.xml session.save() session.createquery( from Track as track ) session.getnamedquery( tracksnolongerthan ); 1 / 20 Configuring Hibernate using XML (hibernate.cfg.xml)...

More information

TP 6 des architectures logicielles Séance 6 : Architecture n-tiers avec du JPA avec plusieurs entités. 1 Préparation de l environnement Eclipse

TP 6 des architectures logicielles Séance 6 : Architecture n-tiers avec du JPA avec plusieurs entités. 1 Préparation de l environnement Eclipse TP 6 des architectures logicielles Séance 6 : Architecture n-tiers avec du JPA avec plusieurs entités 1 Préparation de l environnement Eclipse 1. Environment Used JDK 7 (Java SE 7) JPA 2.0 Eclipse MySQL

More information

Advanced Web Systems 9- Hibernate annotations, Spring integration, Aspect Oriented Programming. A. Venturini

Advanced Web Systems 9- Hibernate annotations, Spring integration, Aspect Oriented Programming. A. Venturini Advanced Web Systems 9- Hibernate annotations, Spring integration, Aspect Oriented Programming A. Venturini Contents Hibernate Core Classes Hibernate and Annotations Data Access Layer with Spring Aspect

More information

Tutorial Hibernate Annotaion Simple Book Library

Tutorial Hibernate Annotaion Simple Book Library Tutorial Hibernate Annotaion Simple Book Library 1. Create Java Project. 2. Add Hibernate Library. 3. Source Folder, create hibernate configuration file (hibernate.cfg.xml). Done. 4. Source Folder, create

More information

UNIVERSIDAD TÉCNICA DEL NORTE

UNIVERSIDAD TÉCNICA DEL NORTE UNIVERSIDAD TÉCNICA DEL NORTE Facultad de Ingeniería en Ciencias Aplicadas Carrera de Ingeniería en Sistemas Informáticos Computacionales TRABAJO DE GRADO PREVIO A LA OBTENCIÓN DEL TÍTULO DE INGENÍERA

More information

JPA Entities. Course Multi Tier Business Applications with Java EE. Prof. Dr. Eric Dubuis Berner Fachhochschule Biel. Berner Fachhochschule

JPA Entities. Course Multi Tier Business Applications with Java EE. Prof. Dr. Eric Dubuis Berner Fachhochschule Biel. Berner Fachhochschule Berner Fachhochschule Technik und Informatik JPA Entities Course Multi Tier Business Applications with Java EE Prof. Dr. Eric Dubuis Berner Fachhochschule Biel Content Characteristics of entities Programming

More information

EJB 3 Entities. Course Multi Tier Business Applications with Java EE. Prof. Dr. Eric Dubuis Berner Fachhochschule Biel. Berner Fachhochschule

EJB 3 Entities. Course Multi Tier Business Applications with Java EE. Prof. Dr. Eric Dubuis Berner Fachhochschule Biel. Berner Fachhochschule Berner Fachhochschule Technik und Informatik EJB 3 Entities Course Multi Tier Business Applications with Java EE Prof. Dr. Eric Dubuis Berner Fachhochschule Biel Content Characteristics of entities Programming

More information

International Journal of Advance Research in Engineering, Science & Technology HIBERNATE FRAMEWORK FOR ENTERPRISE APPLICATION

International Journal of Advance Research in Engineering, Science & Technology HIBERNATE FRAMEWORK FOR ENTERPRISE APPLICATION Impact Factor (SJIF): 3.632 International Journal of Advance Research in Engineering, Science & Technology e-issn: 2393-9877, p-issn: 2394-2444 Volume 4, Issue 3, March-2017 HIBERNATE FRAMEWORK FOR ENTERPRISE

More information

Introduction to JPA. Fabio Falcinelli

Introduction to JPA. Fabio Falcinelli Introduction to JPA Fabio Falcinelli Me, myself and I Several years experience in active enterprise development I love to design and develop web and standalone applications using Python Java C JavaScript

More information

Entities are classes that need to be persisted, usually in a relational database. In this chapter we cover the following topics:

Entities are classes that need to be persisted, usually in a relational database. In this chapter we cover the following topics: Entities are classes that need to be persisted, usually in a relational database. In this chapter we cover the following topics: EJB 3 entities Java persistence API Mapping an entity to a database table

More information

Create a Java project named week9

Create a Java project named week9 Objectives of today s lab: Through this lab, students will explore a hierarchical model for object-oriented design and examine the capabilities of the Java language provides for inheritance and polymorphism.

More information

Selecting a Primary Key - 2

Selecting a Primary Key - 2 Software Architectures and Methodologies A.A 2016/17 Java Persistence API Mapping, Inheritance and Performance Primary Key Dipartimento di Ingegneria dell'informazione Laboratorio Tecnologie del Software

More information

About 1. Chapter 1: Getting started with jpa 2. Remarks 2. Metadata 2. Object-Relational Entity Architecture 2. Versions 2.

About 1. Chapter 1: Getting started with jpa 2. Remarks 2. Metadata 2. Object-Relational Entity Architecture 2. Versions 2. jpa #jpa Table of Contents About 1 Chapter 1: Getting started with jpa 2 Remarks 2 Metadata 2 Object-Relational Entity Architecture 2 Versions 2 Examples 2 Installation or Setup 2 Classpath requirements

More information

Java Persistence API (JPA) Entities

Java Persistence API (JPA) Entities Java Persistence API (JPA) Entities JPA Entities JPA Entity is simple (POJO) Java class satisfying requirements of JavaBeans specification Setters and getters must conform to strict form Every entity must

More information

Model Driven Architecture with Java

Model Driven Architecture with Java Model Driven Architecture with Java Gregory Cranz Solutions Architect Arrow Electronics, Inc. V20061005.1351 Page Number.1 Who am I? Solutions Architect Software Developer Java Early Adopter Page Number.2

More information

Produced by. Agile Software Development. Eamonn de Leastar

Produced by. Agile Software Development. Eamonn de Leastar Agile Software Development Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie Xtend Programming

More information

Xtend Programming Language

Xtend Programming Language Xtend Programming Language Produced by: Eamonn de Leastar (edeleastar@wit.ie) Department of Computing and Mathematics http://www.wit.ie/ Agenda Subtitle Excellent Xtend User Guide (Version 2.6) API Docs

More information

Integration Of Struts2 And Hibernate Frameworks

Integration Of Struts2 And Hibernate Frameworks Integration Of Struts2 And Hibernate Frameworks Remya P V 1, Aswathi R S 1, Swetha M 1, Sijil Sasidharan 1, Sruthi E 1, Vipin Kumar N 1 1 (Department of MCA,NMAMIT Nitte/ Autonomous under VTU, India) ABSTRACT:

More information

Produced by. Agile Software Development. Eamonn de Leastar

Produced by. Agile Software Development. Eamonn de Leastar Agile Software Development Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie Xtend Programming

More information

Exploring EJB3 With JBoss Application Server Part 6.2

Exploring EJB3 With JBoss Application Server Part 6.2 By Swaminathan Bhaskar 01/24/2009 Exploring EJB3 With JBoss Application Server Part 6.2 In this part, we will continue to explore Entity Beans Using Java Persistence API (JPA). Thus far, we have seen examples

More information

XSTREAM - QUICK GUIDE XSTREAM - OVERVIEW

XSTREAM - QUICK GUIDE XSTREAM - OVERVIEW XSTREAM - QUICK GUIDE http://www.tutorialspoint.com/xstream/xstream_quick_guide.htm Copyright tutorialspoint.com XSTREAM - OVERVIEW XStream is a simple Java-based library to serialize Java objects to XML

More information

Chapter 2. Introduction to Mapping

Chapter 2. Introduction to Mapping Chapter 2. Introduction to Mapping 1 / 20 Class and Table Generation of Track TRACK id title filepath

More information

MYBATIS - ANNOTATIONS

MYBATIS - ANNOTATIONS MYBATIS - ANNOTATIONS http://www.tutorialspoint.com/mybatis/mybatis_annotations.htm Copyright tutorialspoint.com In the previous chapters, we have seen how to perform curd operations using MyBatis. There

More information

Advanced Programming Methods. Seminar 12

Advanced Programming Methods. Seminar 12 Advanced Programming Methods Seminar 12 1. instanceof operator 2. Java Serialization Overview 3. Discuss how we can serialize our ToyLanguage interpreter. Please discuss the implementation of different

More information

Webservice Inheritance

Webservice Inheritance Webservice Inheritance Example webservice-inheritance can be browsed at https://github.com/apache/tomee/tree/master/examples/webservice-inheritance Help us document this example! Click the blue pencil

More information

INTERFACE WHY INTERFACE

INTERFACE WHY INTERFACE INTERFACE WHY INTERFACE Interfaces allow functionality to be shared between objects that agree to a contract on how the software should interact as a unit without needing knowledge of how the objects accomplish

More information

Hibernate Quickly by Patrick Peak and Nick Heudecker Chapter 3

Hibernate Quickly by Patrick Peak and Nick Heudecker Chapter 3 Hibernate Quickly by Patrick Peak and Nick Heudecker Chapter 3 Brief contents 1 Why Hibernate? 1 2 Installing and building projects with Ant 26 3 Hibernate basics 50 4 Associations and components 88 5

More information

Introduction to Session beans. EJB - continued

Introduction to Session beans. EJB - continued Introduction to Session beans EJB - continued Local Interface /** * This is the HelloBean local interface. * * This interface is what local clients operate * on when they interact with EJB local objects.

More information

Advanced Topics on Classes and Objects

Advanced Topics on Classes and Objects Advanced Topics on Classes and Objects EECS2030 B: Advanced Object Oriented Programming Fall 2018 CHEN-WEI WANG Equality (1) Recall that A primitive variable stores a primitive value e.g., double d1 =

More information

Hibernate Interview Questions

Hibernate Interview Questions Hibernate Interview Questions 1. What is Hibernate? Hibernate is a powerful, high performance object/relational persistence and query service. This lets the users to develop persistent classes following

More information

Module 8 The Java Persistence API

Module 8 The Java Persistence API Module 8 The Java Persistence API Objectives Describe the role of the Java Persistence API (JPA) in a Java EE application Describe the basics of Object Relational Mapping Describe the elements and environment

More information

Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB)

Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB) Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB) In this exercise, we will create a simple Android application that uses IBM Bluemix Cloudant NoSQL DB. The application

More information

Introduction to Java Enterprise Edition For Database Application Developer

Introduction to Java Enterprise Edition For Database Application Developer CMP 420/758 Introduction to Java Enterprise Edition For Database Application Developer Department of Mathematics and Computer Science Lehman College, the CUNY 1 Java Enterprise Edition Developers today

More information

Java and XML. XML documents consist of Elements. Each element will contains other elements and will have Attributes. For example:

Java and XML. XML documents consist of Elements. Each element will contains other elements and will have Attributes. For example: Java and XML XML Documents An XML document is a way to represent structured information in a neutral format. The purpose of XML documents is to provide a way to represent data in a vendor and software

More information

Java EE Architecture, Part Three. Java EE architecture, part three 1(69)

Java EE Architecture, Part Three. Java EE architecture, part three 1(69) Java EE Architecture, Part Three Java EE architecture, part three 1(69) Content Requirements on the Integration layer The Database Access Object, DAO Pattern Frameworks for the Integration layer Java EE

More information

Exploring EJB3 With JBoss Application Server Part 6.3

Exploring EJB3 With JBoss Application Server Part 6.3 By Swaminathan Bhaskar 02/07/2009 Exploring EJB3 With JBoss Application Server Part 6.3 In this part, we will continue to explore Entity Beans Using Java Persistence API (JPA). In the previous part, we

More information

Lambico. Reference Guide. Lucio Benfante

Lambico. Reference Guide. Lucio Benfante Reference Guide Lucio Benfante : Reference Guide by Lucio Benfante 1.x-DRAFT Copyright (C) 2009 Team < lucio.benfante@gmail.com [mailto:lucio.benfante@gmail.com]> This file is part of Reference Guide.

More information

What data persistence means? We manipulate data (represented as object state) that need to be stored

What data persistence means? We manipulate data (represented as object state) that need to be stored 1 Data Persistence What data persistence means? We manipulate data (represented as object state) that need to be stored persistently to survive a single run of the application queriably to be able to retrieve/access

More information

WEEK 13 EXAMPLES MONDAY SECTION 2. Author class. public class Author { private static int ID=0; private String AuthorName;

WEEK 13 EXAMPLES MONDAY SECTION 2. Author class. public class Author { private static int ID=0; private String AuthorName; WEEK 13 EXAMPLES MONDAY SECTION 2 Author class public class Author { private static int ID=0; private String AuthorName; private String DOB; public Author() { AuthorName = ""; DOB = ""; public Author(String

More information

= "categories") 1 public class Category implements java.io.serializable { 2 private static final long serialversionuid = 1L;

= categories) 1 public class Category implements java.io.serializable { 2 private static final long serialversionuid = 1L; @Entity @Table(name = "categories") 1 public class Category implements java.io.serializable { 2 private static final long serialversionuid = 1L; @Id @GeneratedValue 3 private Long id; 4 private String

More information

Java Persistence API (JPA)

Java Persistence API (JPA) Java Persistence API (JPA) Petr Křemen petr.kremen@fel.cvut.cz Winter Term 2016 Petr Křemen (petr.kremen@fel.cvut.cz) Java Persistence API (JPA) Winter Term 2016 1 / 53 Contents 1 Data Persistence 2 From

More information

Chapter 4. Collections and Associations

Chapter 4. Collections and Associations Chapter 4. Collections and Associations Collections Associations 1 / 51 Java Variable and Collection class Person { Address address; class Address { Set persons = new HashSet; 2 / 51 Java

More information

EXAMINATION FOR THE DIPLOMA IN INFORMATION TECHNOLOGY; YEAR 2

EXAMINATION FOR THE DIPLOMA IN INFORMATION TECHNOLOGY; YEAR 2 FACULTY OF SCIENCE AND TECHNOLOGY EXAMINATION FOR THE DIPLOMA IN INFORMATION TECHNOLOGY; YEAR 2 SAMPLE QUESTION Question 1 A class called TV is required by a programmer who is writing software for a retail

More information

CMSC 132: Object-Oriented Programming II. Inheritance

CMSC 132: Object-Oriented Programming II. Inheritance CMSC 132: Object-Oriented Programming II Inheritance 1 Mustang vs Model T Ford Mustang Ford Model T 2 Interior: Mustang vs Model T 3 Frame: Mustang vs Model T Mustang Model T 4 Compaq: old and new Price:

More information

PART 1. Eclipse IDE Tutorial. 1. What is Eclipse? Eclipse Java IDE

PART 1. Eclipse IDE Tutorial. 1. What is Eclipse? Eclipse Java IDE PART 1 Eclipse IDE Tutorial Eclipse Java IDE This tutorial describes the usage of Eclipse as a Java IDE. It describes the installation of Eclipse, the creation of Java programs and tips for using Eclipse.

More information

Distributed Systems Recitation 1. Tamim Jabban

Distributed Systems Recitation 1. Tamim Jabban 15-440 Distributed Systems Recitation 1 Tamim Jabban Office Hours Office 1004 Sunday, Tuesday: 9:30-11:59 AM Appointment: send an e-mail Open door policy Java: Object Oriented Programming A programming

More information

Spring Data JPA, QueryDSL 실습 JPAQueryFactory 이용

Spring Data JPA, QueryDSL 실습 JPAQueryFactory 이용 Spring Data JPA, QueryDSL 실습 JPAQueryFactory 이용 이전예제의 QueryDSL 작성부분만 JPAQueryFactory 를사용하여구현해보자. 다른점은 JPAQueryFactory 인스턴스생성을위해스프링부트메인에 @Bean 으로정의한부분과 EmpRepositoryImpl 의쿼리작성부분이조금다르고 groupby 처리메소드가추가되었다.

More information

JPA. Java persistence API

JPA. Java persistence API JPA Java persistence API JPA Entity classes JPA Entity classes are user defined classes whose instances can be stored in a database. JPA Persistable Types The term persistable types refers to data types

More information

ibatis, Hibernate, and JPA: Which is right for you?

ibatis, Hibernate, and JPA: Which is right for you? Sponsored by: This story appeared on JavaWorld at http://www.javaworld.com/javaworld/jw-07-2008/jw-07-orm-comparison.html ibatis, Hibernate, and JPA: Which is right for you? Object-relational mapping solutions

More information

Painless Persistence. Some guidelines for creating persistent Java applications that work

Painless Persistence. Some guidelines for creating persistent Java applications that work Painless Persistence Some guidelines for creating persistent Java applications that work The Authors Anthony Patricio Senior JBoss Certification Developer Highest volume poster on early Hibernate forums

More information

Dali Java Persistence Tools. User Guide Release for Eclipse

Dali Java Persistence Tools. User Guide Release for Eclipse Dali Java Persistence Tools User Guide Release 1.0.0 for Eclipse May 2007 Dali Java Persistence Tools User Guide Copyright 2006, 2007 Oracle. All rights reserved. The Eclipse Foundation makes available

More information

Class Relationships. Lecture 18. Based on Slides of Dr. Norazah Yusof

Class Relationships. Lecture 18. Based on Slides of Dr. Norazah Yusof Class Relationships Lecture 18 Based on Slides of Dr. Norazah Yusof 1 Relationships among Classes Association Aggregation Composition Inheritance 2 Association Association represents a general binary relationship

More information

So, this tutorial is divided into various chapters for the simple presentation and easy understanding.

So, this tutorial is divided into various chapters for the simple presentation and easy understanding. MYBATIS 1 About the Tutorial MYBATIS is a persistence framework that automates the mapping among SQL databases and objects in Java,.NET, and Ruby on Rails. MYBATIS makes it easier to build better database

More information

Distributed Systems Recitation 1. Tamim Jabban

Distributed Systems Recitation 1. Tamim Jabban 15-440 Distributed Systems Recitation 1 Tamim Jabban Office Hours Office 1004 Tuesday: 9:30-11:59 AM Thursday: 10:30-11:59 AM Appointment: send an e-mail Open door policy Java: Object Oriented Programming

More information

1 st Step. Prepare the class to be persistent:

1 st Step. Prepare the class to be persistent: 1 st Step Prepare the class to be persistent: Add a surrogate id field, usually int, long, Integer, Long. Encapsulate fields (properties) using exclusively getter and setter methods. Make the setter of

More information

import org.simpleframework.xml.default; import org.simpleframework.xml.element; import org.simpleframework.xml.root;

import org.simpleframework.xml.default; import org.simpleframework.xml.element; import org.simpleframework.xml.root; C:/Users/dsteil/Documents/JavaSimpleXML/src/main/java/com/mycompany/consolecrudexample/Address.java / To change this template, choose Tools Templates and open the template in the editor. import org.simpleframework.xml.default;

More information

Chapter 7. The Annotations Alternative

Chapter 7. The Annotations Alternative Chapter 7. The Annotations Alternative Hibernate Annotations 1 / 33 Hibernate Annotations Java Annotation is a way to add information about a piece of code (typically a class, field, or method to help

More information

SDN Community Contribution

SDN Community Contribution SDN Community Contribution (This is not an official SAP document.) Disclaimer & Liability Notice This document may discuss sample coding or other information that does not include SAP official interfaces

More information

Get Back in Control of your SQL

Get Back in Control of your SQL Get Back in Control of your SQL SQL and Java could work together so much better if we only let them. About my motivation SQL dominates database systems SQL seems «low level» and «dusty» SQL can do so much

More information

InfiniteGraph Manual 1

InfiniteGraph Manual 1 InfiniteGraph Manual 1 Installation Steps: Run the InfiniteGraph.exe file. Click next. Specify the installation directory. Click next. Figure 1: Installation step 1 Figure 2: Installation step 2 2 Select

More information

Exercise 1: Class Employee: public class Employee { private String firstname; private String lastname; private double monthlysalary;

Exercise 1: Class Employee: public class Employee { private String firstname; private String lastname; private double monthlysalary; Exercise 1: Class Employee: public class Employee { private String firstname; private String lastname; private double monthlysalary; public String getfirstname() { return firstname; public void setfirstname(string

More information

Kotlin for Android developers

Kotlin for Android developers ROME - APRIL 13/14 2018 Kotlin for Android developers Victor Kropp, JetBrains @kropp Kotlin on JVM + Android JS In development: Kotlin/Native ios/macos/windows/linux Links Kotlin https://kotlinlang.org

More information

Java Object/Relational Persistence with Hibernate. David Lucek 11 Jan 2005

Java Object/Relational Persistence with Hibernate. David Lucek 11 Jan 2005 Java Object/Relational Persistence with Hibernate David Lucek 11 Jan 2005 Object Relational Persistence Maps objects in your Model to a datastore, normally a relational database. Why? EJB Container Managed

More information

/smlcodes /smlcodes /smlcodes HIBERNATE TUTORIAL. Small Codes. Programming Simplified. A SmlCodes.Com Small presentation

/smlcodes /smlcodes /smlcodes HIBERNATE TUTORIAL. Small Codes. Programming Simplified. A SmlCodes.Com Small presentation /smlcodes /smlcodes /smlcodes HIBERNATE TUTORIAL Small Codes Programming Simplified A SmlCodes.Com Small presentation In Association with Idleposts.com For more tutorials & Articles visit SmlCodes.com

More information

EJB 3 Entity Relationships

EJB 3 Entity Relationships Berner Fachhochschule Technik und Informatik EJB 3 Entity Relationships Course Multi Tier Business Applications with Java EE Prof. Dr. Eric Dubuis Berner Fachhochschule Biel Content What are relationships?

More information

SSE3052: Embedded Systems Practice

SSE3052: Embedded Systems Practice SSE3052: Embedded Systems Practice Minwoo Ahn minwoo.ahn@csl.skku.edu Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu SSE3052: Embedded Systems Practice, Spring 2018, Jinkyu Jeong

More information

Software and Programming 1

Software and Programming 1 Software and Programming 1 Week 9 Lab - Use of Classes and Inheritance 8th March 2018 SP1-Lab9-2018.ppt Tobi Brodie (Tobi@dcs.bbk.ac.uk) 1 Lab 9: Objectives Exercise 1 Student & StudentTest classes 1.

More information

ORM and JPA 2.0. Zdeněk Kouba, Petr Křemen

ORM and JPA 2.0. Zdeněk Kouba, Petr Křemen ORM and JPA 2.0 Zdeněk Kouba, Petr Křemen Compound primary keys Id Class public class EmployeeId implements Serializable { private String country; private int id; @IdClass(EmployeeId.class) public class

More information

Inheritance (Part 5) Odds and ends

Inheritance (Part 5) Odds and ends Inheritance (Part 5) Odds and ends 1 Static Methods and Inheritance there is a significant difference between calling a static method and calling a non-static method when dealing with inheritance there

More information

Abstract Classes and Interfaces

Abstract Classes and Interfaces Abstract Classes and Interfaces Reading: Reges and Stepp: 9.5 9.6 CSC216: Programming Concepts Sarah Heckman 1 Abstract Classes A Java class that cannot be instantiated, but instead serves as a superclass

More information

Lightweight J2EE Framework

Lightweight J2EE Framework Lightweight J2EE Framework Struts, spring, hibernate Software System Design Zhu Hongjun Session 4: Hibernate DAO Refresher in Enterprise Application Architectures Traditional Persistence and Hibernate

More information

Communication Software Exam 5º Ingeniero de Telecomunicación January 26th Name:

Communication Software Exam 5º Ingeniero de Telecomunicación January 26th Name: Duration: Marks: 2.5 hours (+ half an hour for those students sitting part III) 8 points (+ 1 point for part III, for those students sitting this part) Part II: problems Duration: 2 hours Marks: 4 points

More information

JPA - ENTITY MANAGERS

JPA - ENTITY MANAGERS JPA - ENTITY MANAGERS http://www.tutorialspoint.com/jpa/jpa_entity_managers.htm Copyright tutorialspoint.com This chapter takes you through simple example with JPA. Let us consider employee management

More information

COMP200 - Object Oriented Programming: Test One Duration - 60 minutes

COMP200 - Object Oriented Programming: Test One Duration - 60 minutes COMP200 - Object Oriented Programming: Test One Duration - 60 minutes Study the following class and answer the questions that follow: package shapes3d; public class Circular3DShape { private double radius;

More information

Thu 10/26/2017. Created RESTful Web Service, JavaDB, Java Persistence API, Glassfish server in NetBeans 8

Thu 10/26/2017. Created RESTful Web Service, JavaDB, Java Persistence API, Glassfish server in NetBeans 8 Created RESTful Web Service, JavaDB, Java Persistence API, Glassfish server in NetBeans 8 1 tutorial at http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/restfulwebservices/restfulwebservices.htm

More information

Java Classes, Inheritance, and Interfaces

Java Classes, Inheritance, and Interfaces Java Classes, Inheritance, and Interfaces Introduction Classes are a foundational element in Java. Everything in Java is contained in a class. Classes are used to create Objects which contain the functionality

More information

find() method, 178 forclass() method, 162 getcurrentsession(), 16 getexecutablecriteria() method, 162 get() method, 17, 177 getreference() method, 178

find() method, 178 forclass() method, 162 getcurrentsession(), 16 getexecutablecriteria() method, 162 get() method, 17, 177 getreference() method, 178 Index A accessor() method, 58 Address entity, 91, 100 @AllArgsConstructor annotations, 106 107 ArrayList collection, 110 Arrays, 116 Associated objects createalias() method, 165 166 createcriteria() method,

More information

COMP200 INHERITANCE. OOP using Java, from slides by Shayan Javed

COMP200 INHERITANCE. OOP using Java, from slides by Shayan Javed 1 1 COMP200 INHERITANCE OOP using Java, from slides by Shayan Javed 2 Inheritance Derive new classes (subclass) from existing ones (superclass). Only the Object class (java.lang) has no superclass Every

More information

EJB 3 Entity Relationships

EJB 3 Entity Relationships Berner Fachhochschule Technik und Informatik EJB 3 Entity Relationships Course Multi Tier Business Applications with Java EE Prof. Dr. Eric Dubuis Berner Fachhochschule Biel Content What are relationships?

More information

Polymorphism. return a.doublevalue() + b.doublevalue();

Polymorphism. return a.doublevalue() + b.doublevalue(); Outline Class hierarchy and inheritance Method overriding or overloading, polymorphism Abstract classes Casting and instanceof/getclass Class Object Exception class hierarchy Some Reminders Interfaces

More information

Assignment 2 Bootstrap

Assignment 2 Bootstrap Assignment 2 Bootstrap The API + Command Line Specification Walking Skeleton Walking Skeleton : http://alistair.cockburn.us/walking+skeleton A Walking Skeleton is a tiny implementation of the system that

More information

The Object Class. java.lang.object. Important Methods In Object. Mark Allen Weiss Copyright 2000

The Object Class. java.lang.object. Important Methods In Object. Mark Allen Weiss Copyright 2000 The Object Class Mark Allen Weiss Copyright 2000 1/4/02 1 java.lang.object All classes either extend Object directly or indirectly. Makes it easier to write generic algorithms and data structures Makes

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 02: Using Objects MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Using Objects 2 Introduction to Object Oriented Programming Paradigm Objects and References Memory Management

More information

The class Object. Lecture CS1122 Summer 2008

The class Object.  Lecture CS1122 Summer 2008 The class Object http://www.javaworld.com/javaworld/jw-01-1999/jw-01-object.html Lecture 10 -- CS1122 Summer 2008 Review Object is at the top of every hierarchy. Every class in Java has an IS-A relationship

More information

Name Return type Argument list. Then the new method is said to override the old one. So, what is the objective of subclass?

Name Return type Argument list. Then the new method is said to override the old one. So, what is the objective of subclass? 1. Overriding Methods A subclass can modify behavior inherited from a parent class. A subclass can create a method with different functionality than the parent s method but with the same: Name Return type

More information

Inheritance and Polymorphism

Inheritance and Polymorphism Object Oriented Programming Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. Al-Azhar University Website: eaymanelshenawy.wordpress.com Email : eaymanelshenawy@azhar.edu.eg

More information

Topics in Enterprise Information Management

Topics in Enterprise Information Management Topics in Enterprise Information Management Dr. Ilan Kirsh JPA Basics Object Database and ORM Standards and Products ODMG 1.0, 2.0, 3.0 TopLink, CocoBase, Castor, Hibernate,... EJB 1.0, EJB 2.0: Entity

More information

Goals for Today. CSE1030 Introduction to Computer Science II. CSE1030 Lecture #9. Review is-a versus has-a. Lecture #9 Inheritance I

Goals for Today. CSE1030 Introduction to Computer Science II. CSE1030 Lecture #9. Review is-a versus has-a. Lecture #9 Inheritance I CSE1030 Introduction to Computer Science II Lecture #9 Inheritance I Goals for Today Today we start discussing Inheritance (continued next lecture too) This is an important fundamental feature of Object

More information

Java Persistence for Relational Databases RICHARD SPERKO

Java Persistence for Relational Databases RICHARD SPERKO Java Persistence for Relational Databases RICHARD SPERKO Java Persistence for Relational Databases Copyright 2003 by Richard Sperko All rights reserved. No part of this work may be reproduced or transmitted

More information

Object Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming

Object Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming Overview of OOP Object Oriented Programming is a programming method that combines: a) Data b) Instructions for processing that data into a self-sufficient object that can be used within a program or in

More information

Assignment-1 Final Code. Student.java

Assignment-1 Final Code. Student.java package com.ds.assgn1a; public class Student { public int rollno; public String name; public double marks; Assignment-1 Final Code Student.java public Student(int rollno, String name, double marks){ this.rollno

More information

WEEK 13 EXAMPLES: POLYMORPHISM

WEEK 13 EXAMPLES: POLYMORPHISM WEEK 13 EXAMPLES: POLYMORPHISM CASE STUDY: PAYROLL SYSTEM USING POLYMORPHISM Use the principles of inheritance, abstract class, abstract method, and polymorphism to design a payroll project for a car lot.

More information