Exploring EJB3 With JBoss Application Server Part 6.3

Size: px
Start display at page:

Download "Exploring EJB3 With JBoss Application Server Part 6.3"

Transcription

1 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 had explored the one-to-one and many-to-one entity relationships. In the following paragraphs, we will be looking at one-to-many and many-to-many entity relationships. Let us explore the one-to-many entity relationship. There could be two types of one-to-many relationships Unidirectional or Bidirectional. The relationship between any Team and its Players is one-to-many unidirectional relationship because we look up all the Players in a given Team and not vice versa. The following diagram illustrates the relationship: Before we proceed with the example, we need to setup the two tables in the MySQL database testdb as follows: CREATE TABLE TEAM_TBL ( TEAM_ID INTEGER AUTO_INCREMENT, TEAM_NAME VARCHAR(25) NOT NULL, TEAM_STATE CHAR(2) NOT NULL, PRIMARY KEY PK_TEAM_ID(TEAM_ID) ); CREATE TABLE PLAYER_TBL ( PLAYER_NAME VARCHAR(30) NOT NULL, PLAYER_HEIGHT VARCHAR(8) NOT NULL, TEAM INTEGER, PRIMARY KEY PK_PLAYER_NAME(PLAYER_NAME), CONSTRAINT PLAYER_TEAM_FK FOREIGN KEY (TEAM) REFERENCES TEAM_TBL(TEAM_ID) ); The following code shows the Player Entity Bean: /* * Name: Bhaskar S * * Date: 02/07/2009 */ package teamplay.common;

2 public class Player implements java.io.serializable { private static final long serialversionuid private String private String height; public String getname() { return name; public void setname(string n) { name = n; public String getheight() { return height; public void setheight(string n) { height = n; public String tostring() { StringBuffer sb = new StringBuffer(); sb.append("player name: "); sb.append(name); sb.append(", Player height: "); sb.append(height); return sb.tostring(); The Player entity uses player name as the primary key column (PLAYER_NAME). The following code shows the Team Entity Bean: /* * Name: Bhaskar S * * Date: 02/07/2009 */ package teamplay.common; import java.util.*; public class Team implements java.io.serializable { private static final long serialversionuid = private int id;

3 @Column(name="TEAM_NAME") private String private private Collection<Player> players = new ArrayList<Player>(); public int getid() { return id; public void setid(int n) { id = n; public String getname() { return name; public void setname(string n) { name = n; public String getstate() { return state; public void setstate(string n) { state = n; public Collection<Player> getplayers() { return players; public void setplayers(collection<player> p) { players = p; public String tostring() { StringBuffer sb = new StringBuffer(); sb.append("-> Team Id: "); sb.append(id); sb.append(", Team name: "); sb.append(name); sb.append(", Team state: "); sb.append(state); sb.append("\n"); for (Player p : players) { sb.append("\t-> "); sb.append(p.tostring()); sb.append("\n"); return sb.tostring(); The Team entity uses auto generated primary key column (TEAM_ID). annotation indicates the one-to-many relationship between any Team and its associated Player entities. annotation indicates the foreign key column in the Player entity that references the primary key column in the Team entity. This is what ties the Player to the Team. Since there can be more than one Player per Team, it is represented by a collection data structure in the Team entity Collection<Player>.

4 The following code shows the Remote interface for TeamPlayer: /* * Name: Bhaskar S * * Date: 02/07/2009 */ package teamplay.remote; import javax.ejb.remote; import public interface TeamPlayer { public void addteam(string name, String state); public void addplayer(string team, String name, String height) throws Exception; public void updateplayer(string name, String height) throws Exception; public void removeplayer(string name) throws Exception; public Team getteam(string name) throws Exception; public void removeteam(string name) throws Exception; The TeamPlayer interface allows us to perform various operation on the Player and Team entities. The following shows the code for TeamPlayerBean stateless session bean: /* * Name: Bhaskar S * * Date: 02/07/2009 */ package teamplay.ejb; import teamplay.common.*; import teamplay.remote.teamplayer; import java.util.*; import javax.ejb.stateless; import javax.persistence.entitymanager; import javax.persistence.persistencecontext; import public class TeamPlayerBean implements TeamPlayer private EntityManager _emgr; public void addteam(string name, String state) { Team team = new Team(); team.setname(name);

5 team.setstate(state); _emgr.persist(team); public void addplayer(string team, String name, String height) throws Exception { Query qry = _emgr.createquery("select t from Team t where t.name = '" + team + "'"); List<Team> lst = qry.getresultlist(); if (lst.size() == 0) { throw new Exception("No team found with name " + team); Team tm = lst.get(0); System.out.println("-> AddPlayer: " + tm); Player player = new Player(); player.setname(name); player.setheight(height); tm.getplayers().add(player); // Uncomment the following if you dont use cascade attribute in OneToMany in Team // _emgr.persist(player); // _emgr.merge(tm); public void updateplayer(string name, String height) throws Exception { Player player = _emgr.find(player.class, name); if (player == null) { throw new Exception("No player found with name " + name); player.setheight(height); public void removeplayer(string name) throws Exception { Player player = _emgr.find(player.class, name); if (player == null) { throw new Exception("No player found with name " + name); _emgr.remove(player); public Team getteam(string name) throws Exception { Query qry = _emgr.createquery("select t from Team t where t.name = '" + name + "'"); List<Team> lst = qry.getresultlist(); if (lst.size() == 0) { throw new Exception("No team found with name " + name); Team tm = lst.get(0); System.out.println("-> GetTeam: " + tm); return tm; public void removeteam(string name) throws Exception { Query qry = _emgr.createquery("select t from Team t where t.name = '" + name + "'"); List<Team> lst = qry.getresultlist(); if (lst.size() == 0) { throw new Exception("No team found with name " + name); Team tm = lst.get(0); System.out.println("-> RemoveTeam: " + tm); // Uncomment the following if you dont use cascade attribute in OneToMany in Team // for (Player p : tm.getplayers()) { // _emgr.remove(p); // _emgr.remove(tm);

6 The highlighted line in the above code indicates the use of custom Query in JPA. Remember that Team entity uses team id (TEAM_ID) as the primary key. Since we only have the team name and not its team id, we cannot use find method for lookup. The only other option is to use the Query API from JPA. The Query API uses the EJB QL (query language) to query for entities from the database. EJB QL looks and feels like the SQL syntax, which we are all so familiar with. The difference is that EJB QL works with Java entities rather than tables and columns as in SQL. In the above code, we are querying the database using EJB QL for a Team with the specified team name. The following shows the code for a standalone client that is accessing the TeamPlayerBean stateless session bean through the remote interface TeamPlayer: /* * Name: Bhaskar S * * Date: 02/07/2009 */ package teamplay.client; import teamplay.common.*; import teamplay.remote.teamplayer; import java.io.bufferedreader; import java.io.inputstreamreader; import javax.naming.context; import javax.naming.initialcontext; public class TeamPlayerClient { public static void main(string[] args) { BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); Context ctx = new InitialContext(); TeamPlayer tp = (TeamPlayer) ctx.lookup("teamplayer/remote"); boolean exit = false; while (! exit) { System.out.println("1. Add Team"); System.out.println(""); System.out.println(""); System.out.println(""); System.out.println(""); System.out.println(""); System.out.println(""); String choice = input.readline(); if (choice.equals("1")) { System.out.print("Team Name: "); String name = input.readline(); System.out.print("Team State: "); String state = input.readline(); tp.addteam(name, state); System.out.println("-> Added Team, Name: " + name + ", State: " + state); else if (choice.equals("2")) { System.out.print("Player Name: "); String name = input.readline(); System.out.print("Player Height: "); String height = input.readline(); System.out.print("Player Team: "); String team = input.readline(); tp.addplayer(team, name, height);

7 System.out.println("-> Added Player, Name: " + name + ", Height: " + height + ", Team: " + team); catch (Exception ex) { else if (choice.equals("3")) { System.out.print("Player Name: "); String name = input.readline(); System.out.print("Player Height: "); String height = input.readline(); tp.updateplayer(name, height); System.out.println("-> Updated Player, Name: " + name + ", Height: " + height); catch (Exception ex) { else if (choice.equals("4")) { System.out.print("Player Name: "); String name = input.readline(); tp.removeplayer(name); System.out.println("-> Removed Player, Name: " + name); catch (Exception ex) { else if (choice.equals("5")) { System.out.print("Team Name: "); String name = input.readline(); Team team = null; team = tp.getteam(name); catch (Exception ex) { System.out.println("-> Team " + team); else if (choice.equals("6")) { System.out.print("Team Name: "); String name = input.readline(); tp.removeteam(name); catch (Exception ex) { System.out.println("-> Removed Team Name: " + name); else if (choice.equals("7")) { exit = true; catch (Throwable ex) { Next, we will compile and deploy the EJB jar my_ejb_beans.jar into the JBoss Application Server. Now, open a Terminal window and execute the script TeamPlayer.sh as illustrated below:

8 $./TeamPlayer.sh 1. Add Team 1 Team Name: Team-1 Team State: NJ -> Added Team, Name: Team-1, State: NJ 1. Add Team 1 Team Name: Team-2 Team State: NY -> Added Team, Name: Team-2, State: NY 1. Add Team 2 Player Name: Player-1 Player Height: 5ft 11in Player Team: Team-1 -> Added Player, Name: Player-1, Height: 5ft 11in, Team: Team-1 1. Add Team 2 Player Name: Player-2 Player Height: 6ft 2in Player Team: Team-2 -> Added Player, Name: Player-2, Height: 6ft 2in, Team: Team-2

9 1. Add Team 2 Player Name: Player-3 Player Height: 5ft 10in Player Team: Team-1 -> Added Player, Name: Player-3, Height: 5ft 10in, Team: Team-1 1. Add Team 2 Player Name: Player-4 Player Height: 6ft 3in Player Team: Team-2 -> Added Player, Name: Player-4, Height: 6ft 3in, Team: Team-2 1. Add Team We can verify the data from the database as follows: mysql> select * from TEAM_TBL; TEAM_ID TEAM_NAME TEAM_STATE Team-1 NJ 2 Team-2 NY rows in set (0.00 sec) mysql> select * from PLAYER_TBL; PLAYER_NAME PLAYER_HEIGHT TEAM Player-1 5ft 11in 1 Player-2 6ft 2in 2 Player-3 5ft 10in 1

10 Player-4 6ft 3in rows in set (0.00 sec) 3 Player Name: Player-3 Player Height: 6ft 5in -> Updated Player, Name: Player-3, Height: 6ft 5in 1. Add Team 4 Player Name: Player-3 -> Removed Player, Name: Player-3 1. Add Team 5 Team Name: Team-1 -> Team -> Team Id: 1, Team name: Team-1, Team state: NJ -> Player name: Player-1, Player height: 5ft 11in 1. Add Team 5 Team Name: Team-2 -> Team -> Team Id: 2, Team name: Team-2, Team state: NY -> Player name: Player-2, Player height: 6ft 2in -> Player name: Player-4, Player height: 6ft 3in 1. Add Team

11 6 Team Name: Team-1 -> Removed Team Name: Team-1 1. Add Team We can verify the data from the database as follows: mysql> select * from TEAM_TBL; TEAM_ID TEAM_NAME TEAM_STATE Team-2 NY row in set (0.00 sec) mysql> select * from PLAYER_TBL; PLAYER_NAME PLAYER_HEIGHT TEAM Player-2 6ft 2in 2 Player-4 6ft 3in rows in set (0.00 sec) We have successfully deployed and executed the example depicting the unidirectional one-to-many relationship between any Team and its Players. Next, let us explore the one-to-many bidirectional entity relationship. The relationship between any Person and their Credit-cards is one-to-many bidirectional relationship because we look up all the Credit-cards for a given Person and vice versa. For this example, we will use a join table rather than a join column to make it more interesting. The following diagram illustrates the relationship: Before we proceed with the example, we need to setup the two tables in the MySQL database testdb

12 as follows: CREATE TABLE PERSON_TBL ( PERSON_ID INTEGER AUTO_INCREMENT, PERSON_NAME VARCHAR(25) NOT NULL, PERSON_ZIP VARCHAR(5) NOT NULL, PRIMARY KEY PK_PERSON_ID(PERSON_ID) ); CREATE TABLE CREDIT_CARD_TBL ( CARD_ID INTEGER AUTO_INCREMENT, CARD_NUMBER VARCHAR(16) NOT NULL, CARD_EXPIRY VARCHAR(5) NOT NULL, PRIMARY KEY PK_CARD_ID(CARD_ID) ); CREATE TABLE PERSON_CARD_TBL ( PID INTEGER NOT NULL, CID INTEGER NOT NULL, CONSTRAINT PERSON_ID_FK FOREIGN KEY (PID) REFERENCES PERSON_TBL(PERSON_ID), CONSTRAINT CARD_ID_FK FOREIGN KEY (CID) REFERENCES CREDIT_CARD_TBL(CARD_ID) ); The following code shows the Person Entity Bean: /* * Name: Bhaskar S * * Date: 02/07/2009 */ package percredit.common; import java.util.*; public class Person implements java.io.serializable { private static final long serialversionuid = private int private String private joincolumns={@joincolumn(name="pid"),

13 ) private Collection<CreditCard> cards = new ArrayList<CreditCard>(); public int getid() { return id; public void setid(int n) { id = n; public String getname() { return name; public void setname(string n) { name = n; public String getzip() { return zip; public void setzip(string s) { zip = s; public Collection<CreditCard> getcards() { return cards; public void setcards(collection<creditcard> c) { cards = c; public String tostring() { StringBuffer sb = new StringBuffer(); sb.append("-> Person Id: "); sb.append(id); sb.append(", Person name: "); sb.append(name); sb.append(", Person zip: "); sb.append(zip); sb.append("\n"); for (CreditCard cc : cards) { sb.append("\t-> "); sb.append(cc.tostring()); sb.append("\n"); return sb.tostring(); The Person entity uses auto generated primary key column (PERSON_ID). Each Person can have zero or more credit cards. annotation indicates this one-to-many relationship with the CreditCard entity. From the diagram above, it is clear that we have used a join table PERSON_CARD_TBL to indicate this one-to-many relationship between PERSON_TBL and CREDIT_CARD_TBL. annotation indicates the use of this join table. The joincolumns attribute indicates the foreign key in the join table (PID) that references the primary key of the Person entity (PERSON_ID). The inversejoincolumns attribute indicates the foreign key in the join table (CID) that references the primary key of the related CreditCard entity (CARD_ID). This is the mapping when we are looking at the relationship from the Person entity.

14 The following code shows the CreditCard Entity Bean: /* * Name: Bhaskar S * * Date: 02/07/2009 */ package percredit.common; public class CreditCard implements java.io.serializable { private static final long serialversionuid = private int private String private joincolumns={@joincolumn(name="cid"), inversejoincolumns={@joincolumn(name="pid") ) private Person person; public int getid() { return id; public void setid(int n) { id = n; public String getnumber() { return number; public void setnumber(string n) { number = n; public String getexpiry() { return expiry; public void setexpiry(string s) { expiry = s; public Person getperson() { return person; public void setperson(person p) { person = p; public String tostring() { StringBuffer sb = new StringBuffer();

15 sb.append("-> Card Id: "); sb.append(id); sb.append(", Card number: "); sb.append(number); sb.append(", Card expiry: "); sb.append(expiry); sb.append(", Person: "); if (person!= null) { sb.append(person.getname()); return sb.tostring(); The CreditCard entity uses auto generated primary key column (CARD_ID). Many CreditCard entities may belong to a Person. annotation indicates this many-to-one relationship with the Person entity. annotation indicates the use of the join table PERSON_CARD_TBL. The joincolumns attribute indicates the foreign key in the join table (CID) that references the primary key of the CreditCard entity (CARD_ID). The inversejoincolumns attribute indicates the foreign key in the join table (PID) that references the primary key of the related Person entity (PERSON_ID). This is the mapping when we are looking at the relationship from the CreditCard entity. The following code shows the Remote interface for PersonCard: /* * Name: Bhaskar S * * Date: 02/07/2009 */ package percredit.remote; import javax.ejb.remote; import public interface PersonCard { public void addperson(string name, String zip); public void removeperson(string name) throws Exception; public Person getperson(string name) throws Exception; public void addcreditcard(string name, String number, String expiry) throws Exception; public void removecreditcard(string number) throws Exception; public CreditCard getcreditcard(string number) throws Exception; The PersonCard interface allows us to perform various operation on the Person and CreditCard entities. The following shows the code for PersonCardBean stateless session bean:

16 /* * Name: Bhaskar S * * Date: 02/07/2009 */ package percredit.ejb; import percredit.common.*; import percredit.remote.personcard; import java.util.*; import javax.ejb.stateless; import javax.persistence.entitymanager; import javax.persistence.persistencecontext; import public class PersonCardBean implements PersonCard private EntityManager _emgr; public void addperson(string name, String zip) { Person per = new Person(); per.setname(name); per.setzip(zip); _emgr.persist(per); System.out.println("-> Persisted data for person: " + name); public void removeperson(string name) throws Exception { Query qry = _emgr.createquery("select p from Person p where p.name = '" + name + "'"); List<Person> lst = qry.getresultlist(); if (lst.size() == 0) { throw new Exception("No person found with name: " + name); Person per = lst.get(0); System.out.println("-> Remove person: " + per); _emgr.remove(per); public Person getperson(string name) throws Exception { Query qry = _emgr.createquery("select p from Person p where p.name = '" + name + "'"); List<Person> lst = qry.getresultlist(); if (lst.size() == 0) { throw new Exception("No person found with name: " + name); Person per = lst.get(0); System.out.println("-> Get person: " + per); return per; public void addcreditcard(string name, String number, String expiry) throws Exception { Query qry = _emgr.createquery("select p from Person p where p.name = '" + name + "'"); List<Person> lst = qry.getresultlist(); if (lst.size() == 0) { throw new Exception("No person found with name: " + name); Person per = lst.get(0); System.out.println("-> Lookup person <add-card>: " + per); CreditCard card = new CreditCard(); card.setnumber(number); card.setexpiry(expiry);

17 per.getcards().add(card); System.out.println("-> Added credit card: " + number + " for person: " + per); public void removecreditcard(string number) throws Exception { Query qry = _emgr.createquery("select c from CreditCard c where c.number = '" + number + "'"); List<CreditCard> lst = qry.getresultlist(); if (lst.size() == 0) { throw new Exception("No credit card found with number: " + number); CreditCard card = lst.get(0); System.out.println("-> Remove credit card for person: " + card.getperson().getname()); _emgr.remove(card); public CreditCard getcreditcard(string number) throws Exception { Query qry = _emgr.createquery("select c from CreditCard c where c.number = '" + number + "'"); List<CreditCard> lst = qry.getresultlist(); if (lst.size() == 0) { throw new Exception("No credit card found with number " + number); CreditCard card = lst.get(0); System.out.println("-> Get credit card : " + card); return card; The following shows the code for a standalone client that is accessing the PersonCardBean stateless session bean through the remote interface PersonCard: /* * Name: Bhaskar S * * Date: 02/07/2009 */ package percredit.client; import percredit.common.*; import percredit.remote.personcard; import java.io.bufferedreader; import java.io.inputstreamreader; import javax.naming.context; import javax.naming.initialcontext; public class PersonCardClient { public static void main(string[] args) { BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); Context ctx = new InitialContext(); PersonCard pc = (PersonCard) ctx.lookup("personcard/remote"); boolean exit = false; while (! exit) { System.out.println("1. Add Person"); System.out.println("2. Remove Person"); System.out.println("3. Get Person Information"); System.out.println("4. Add Credit Card"); System.out.println("5. Remove Credit Card"); System.out.println("6. Get Credit Card Information"); System.out.println("");

18 String choice = input.readline(); if (choice.equals("1")) { System.out.print("Person Name: "); String name = input.readline(); System.out.print("Person zip: "); String zip = input.readline(); pc.addperson(name, zip); System.out.println("-> Added Person, Name: " + name + ", Zip: " + zip); else if (choice.equals("2")) { System.out.print("Person Name: "); String name = input.readline(); pc.removeperson(name); System.out.println("-> Removed person, Name: " + name); catch (Exception ex) { else if (choice.equals("3")) { System.out.print("Person Name: "); String name = input.readline(); Person per = null; per = pc.getperson(name); catch (Exception ex) { System.out.println("-> Person: " + per); else if (choice.equals("4")) { System.out.print("Credit Card Owner: "); String name = input.readline(); System.out.print("Credit Card Number: "); String number = input.readline(); System.out.print("Credit Card Expiry: "); String expiry = input.readline(); pc.addcreditcard(name, number, expiry); System.out.println("-> Added Credit Card for Name: " + name); catch (Exception ex) { else if (choice.equals("5")) { System.out.print("Credit Card Number: "); String number = input.readline(); pc.removecreditcard(number); catch (Exception ex) { System.out.println("-> Removed Credit Card with Number: " + number); else if (choice.equals("6")) { System.out.print("Credit Card Number: "); String number = input.readline(); CreditCard card = null; card = pc.getcreditcard(number); catch (Exception ex) { System.out.println("-> Credit Card: " + card); else if (choice.equals("7")) { exit = true;

19 catch (Throwable ex) { Next, we will compile and deploy the EJB jar my_ejb_beans.jar into the JBoss Application Server. Now, open a Terminal window and execute the script PersonCard.sh as illustrated below: $./PersonCard.sh 1. Add Person 2. Remove Person 3. Get Person Information 4. Add Credit Card 5. Remove Credit Card 6. Get Credit Card Information 1 Person Name: Swaminathan Bhaskar Person zip: > Added Person, Name: Swaminathan Bhaskar, Zip: Add Person 2. Remove Person 3. Get Person Information 4. Add Credit Card 5. Remove Credit Card 6. Get Credit Card Information 1 Person Name: Bill Gates Person zip: > Added Person, Name: Bill Gates, Zip: Add Person 2. Remove Person 3. Get Person Information 4. Add Credit Card 5. Remove Credit Card 6. Get Credit Card Information 4 Credit Card Owner: Swaminathan Bhaskar Credit Card Number: Credit Card Expiry: 10/10 -> Added Credit Card for Name: Swaminathan Bhaskar 1. Add Person

20 2. Remove Person 3. Get Person Information 4. Add Credit Card 5. Remove Credit Card 6. Get Credit Card Information 4 Credit Card Owner: Bill Gates Credit Card Number: Credit Card Expiry: 11/11 -> Added Credit Card for Name: Bill Gates 1. Add Person 2. Remove Person 3. Get Person Information 4. Add Credit Card 5. Remove Credit Card 6. Get Credit Card Information 4 Credit Card Owner: Bill Gates Credit Card Number: Credit Card Expiry: 12/12 -> Added Credit Card for Name: Bill Gates 1. Add Person 2. Remove Person 3. Get Person Information 4. Add Credit Card 5. Remove Credit Card 6. Get Credit Card Information 3 Person Name: Bill Gates -> Person: -> Person Id: 2, Person name: Bill Gates, Person zip: > -> Card Id: 2, Card number: , Card expiry: 11/11, Person: Bill Gates -> -> Card Id: 3, Card number: , Card expiry: 12/12, Person: Bill Gates We can verify the data from the database as follows: mysql> select * from PERSON_TBL; PERSON_ID PERSON_NAME PERSON_ZIP Swaminathan Bhaskar Bill Gates rows in set (0.00 sec) mysql> select * from CREDIT_CARD_TBL; CARD_ID CARD_NUMBER CARD_EXPIRY

21 / / / rows in set (0.00 sec) mysql> select * from PERSON_CARD_TBL; PID CID rows in set (0.00 sec) 1. Add Person 2. Remove Person 3. Get Person Information 4. Add Credit Card 5. Remove Credit Card 6. Get Credit Card Information 2 Person Name: Bill Gates -> Removed person, Name: Bill Gates 1. Add Person 2. Remove Person 3. Get Person Information 4. Add Credit Card 5. Remove Credit Card 6. Get Credit Card Information 3 Person Name: Swaminathan Bhaskar -> Person: -> Person Id: 1, Person name: Swaminathan Bhaskar, Person zip: > -> Card Id: 1, Card number: , Card expiry: 10/10, Person: Swaminathan Bhaskar We can verify the data from the database as follows: mysql> select * from PERSON_TBL; PERSON_ID PERSON_NAME PERSON_ZIP Swaminathan Bhaskar row in set (0.00 sec) mysql> select * from CREDIT_CARD_TBL;

22 CARD_ID CARD_NUMBER CARD_EXPIRY / row in set (0.00 sec) mysql> select * from PERSON_CARD_TBL; PID CID row in set (0.01 sec) 1. Add Person 2. Remove Person 3. Get Person Information 4. Add Credit Card 5. Remove Credit Card 6. Get Credit Card Information 7 We have successfully deployed and executed the example depicting the bidirectional one-to-many relationship using a join table between a Person and their CreditCards. We will continue to explore EJB Entity Beans Using Java Persistence in Part-6.4 of this series.

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

Exploring EJB3 With JBoss Application Server Part - 5

Exploring EJB3 With JBoss Application Server Part - 5 By Swaminathan Bhaskar 12/13/2008 Exploring EJB3 With JBoss Application Server Part - 5 In this part, we will first explore EJB Timer Service and then look at Interceptors. 7. EJB Timer Service A Timer

More information

EJB - ACCESS DATABASE

EJB - ACCESS DATABASE EJB - ACCESS DATABASE http://www.tutorialspoint.com/ejb/ejb_access_database.htm Copyright tutorialspoint.com EJB 3.0, persistence mechanism is used to access the database in which container manages the

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

EJB - INTERCEPTORS. Interceptor methods can be applied or bound at three levels

EJB - INTERCEPTORS. Interceptor methods can be applied or bound at three levels http://www.tutorialspoint.com/ejb/ejb_interceptors.htm EJB - INTERCEPTORS Copyright tutorialspoint.com EJB 3.0 provides specification to intercept business methods calls using methods annotated with @AroundInvoke

More information

WHAT IS EJB. Security. life cycle management.

WHAT IS EJB. Security. life cycle management. EJB WHAT IS EJB EJB is an acronym for enterprise java bean. It is a specification provided by Sun Microsystems to develop secured, robust and scalable distributed applications. To run EJB application,

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

Introduction to Session beans EJB 3.0

Introduction to Session beans EJB 3.0 Introduction to Session beans EJB 3.0 Remote Interface EJB 2.1 ===================================================== public interface Hello extends javax.ejb.ejbobject { /** * The one method - hello -

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

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 - DEPENDENCY INJECTION

EJB - DEPENDENCY INJECTION EJB - DEPENDENCY INJECTION http://www.tutorialspoint.com/ejb/ejb_dependency_injection.htm Copyright tutorialspoint.com EJB 3.0 specification provides annotations which can be applied on fields or setter

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

Selected Questions from by Nageshwara Rao

Selected Questions from  by Nageshwara Rao Selected Questions from http://way2java.com by Nageshwara Rao Swaminathan J Amrita University swaminathanj@am.amrita.edu November 24, 2016 Swaminathan J (Amrita University) way2java.com (Nageshwara Rao)

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

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

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

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

Enterprise JavaBeans, Version 3 (EJB3) Programming

Enterprise JavaBeans, Version 3 (EJB3) Programming Enterprise JavaBeans, Version 3 (EJB3) Programming Description Audience This course teaches developers how to write Java Enterprise Edition (JEE) applications that use Enterprise JavaBeans, version 3.

More information

Injection Of Entitymanager

Injection Of Entitymanager Injection Of Entitymanager Example injection-of-entitymanager can be browsed at https://github.com/apache/tomee/tree/master/examples/injection-ofentitymanager This example shows use of @PersistenceContext

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

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

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

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

Refactoring to Seam. NetBeans. Brian Leonard Sun Microsystems, Inc. 14o

Refactoring to Seam. NetBeans. Brian Leonard Sun Microsystems, Inc. 14o Refactoring to Seam NetBeans Brian Leonard Sun Microsystems, Inc. 14o AGENDA 2 > The Java EE 5 Programming Model > Introduction to Seam > Refactor to use the Seam Framework > Seam Portability > Q&A Java

More information

Dynamic Datasource Routing

Dynamic Datasource Routing Dynamic Datasource Routing Example dynamic-datasource-routing can be browsed at https://github.com/apache/tomee/tree/master/examples/dynamic-datasourcerouting The TomEE dynamic datasource api aims to allow

More information

Fast Track to EJB 3.0 and the JPA Using JBoss

Fast Track to EJB 3.0 and the JPA Using JBoss Fast Track to EJB 3.0 and the JPA Using JBoss The Enterprise JavaBeans 3.0 specification is a deep overhaul of the EJB specification that is intended to improve the EJB architecture by reducing its complexity

More information

JPA The New Enterprise Persistence Standard

JPA The New Enterprise Persistence Standard JPA The New Enterprise Persistence Standard Mike Keith michael.keith@oracle.com http://otn.oracle.com/ejb3 About Me Co-spec Lead of EJB 3.0 (JSR 220) Java EE 5 (JSR 244) expert group member Co-author Pro

More information

1Z Oracle. Java Enterprise Edition 5 Business Component Developer Certified Professional Upgrade

1Z Oracle. Java Enterprise Edition 5 Business Component Developer Certified Professional Upgrade Oracle 1Z0-861 Java Enterprise Edition 5 Business Component Developer Certified Professional Upgrade Download Full Version : https://killexams.com/pass4sure/exam-detail/1z0-861 A. The Version attribute

More information

EJB 3.0 Puzzlers. Mike Keith, Oracle Corp. Colorado Software Summit: October 21 26, 2007

EJB 3.0 Puzzlers. Mike Keith, Oracle Corp.   Colorado Software Summit: October 21 26, 2007 EJB 3.0 Puzzlers Mike Keith, Oracle Corp. michael.keith@oracle.com http://otn.oracle.com/ejb3 Slide 1 About Me Co-spec Lead of EJB 3.0 (JSR 220) and Java EE 5 (JSR 244) expert group member Currently working

More information

CS Week 11. Jim Williams, PhD

CS Week 11. Jim Williams, PhD CS 200 - Week 11 Jim Williams, PhD This Week 1. Exam 2 - Thursday 2. Team Lab: Exceptions, Paths, Command Line 3. Review: Muddiest Point 4. Lecture: File Input and Output Objectives 1. Describe a text

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

Session 13. Reading. A/SettingUpJPA.htm JPA Best Practices

Session 13. Reading.  A/SettingUpJPA.htm JPA Best Practices Session 13 DB Persistence (JPA) Reading Reading Java EE 7 Tutorial chapters 37-39 NetBeans/Derby Tutorial www.oracle.com/webfolder/technetwork/tutorials/obe/java/settingupjp A/SettingUpJPA.htm JPA Best

More information

Schema Null Cannot Be Resolved For Table Jpa

Schema Null Cannot Be Resolved For Table Jpa Schema Null Cannot Be Resolved For Table Jpa (14, 19) The abstract schema type 'Movie' is unknown. (28, 35) The state field path 'm.title' cannot be resolved to a valid type. at org.springframework.web.servlet.

More information

Getting started with Java

Getting started with Java Getting started with Java by Vlad Costel Ungureanu for Learn Stuff Programming Languages A programming language is a formal constructed language designed to communicate instructions to a machine, particularly

More information

Integrating NWDS with a Non-SAP Server (JBoss AS) to Develop and Deploy Java EE Applications

Integrating NWDS with a Non-SAP Server (JBoss AS) to Develop and Deploy Java EE Applications Integrating NWDS with a Non-SAP Server (JBoss AS) to Develop and Deploy Java EE Applications Applies to: This article applies to SAP NetWeaver Developer Studio, SAP NetWeaver 7.1 CE SP03 PAT0000 Summary

More information

Simple Stateless with Descriptor

Simple Stateless with Descriptor Simple Stateless with Descriptor Example simple-stateless-with-descriptor can be browsed at https://github.com/apache/tomee/tree/master/examples/simple-stateless-withdescriptor This test is similar to

More information

Dynamic DAO Implementation

Dynamic DAO Implementation Dynamic DAO Implementation Example dynamic-dao-implementation can be browsed at https://github.com/apache/tomee/tree/master/examples/dynamic-daoimplementation Many aspects of Data Access Objects (DAOs)

More information

Lab2: CMP Entity Bean working with Session Bean

Lab2: CMP Entity Bean working with Session Bean Session Bean The session bean in the Lab1 uses JDBC connection to retrieve conference information from the backend database directly. The Lab2 extends the application in Lab1 and adds an new entity bean

More information

SUN Sun Cert Bus Component Developer Java EE Platform 5, Upgrade. Download Full Version :

SUN Sun Cert Bus Component Developer Java EE Platform 5, Upgrade. Download Full Version : SUN 310-092 Sun Cert Bus Component Developer Java EE Platform 5, Upgrade Download Full Version : https://killexams.com/pass4sure/exam-detail/310-092 D. A javax.ejb.nosuchentityexception is thrown. Answer:

More information

Testing Transactions BMT

Testing Transactions BMT Testing Transactions BMT Example testing-transactions-bmt can be browsed at https://github.com/apache/tomee/tree/master/examples/testing-transactions-bmt Shows how to begin, commit and rollback transactions

More information

WES-CS GROUP MEETING #9

WES-CS GROUP MEETING #9 WES-CS GROUP MEETING #9 Exercise 1: Practice Multiple-Choice Questions 1. What is output when the following code executes? String S1 = new String("hello"); String S2 = S1 +! ; S1 = S1 + S1; System.out.println(S1);

More information

jar command Java Archive inherits from tar : Tape Archive commands: jar cvf filename jar tvf filename jar xvf filename java jar filename.

jar command Java Archive inherits from tar : Tape Archive commands: jar cvf filename jar tvf filename jar xvf filename java jar filename. jar & jar files jar command Java Archive inherits from tar : Tape Archive commands: jar cvf filename jar tvf filename jar xvf filename java jar filename.jar jar file A JAR file can contain Java class files,

More information

Stateful Session Beans

Stateful Session Beans Berner Fachhochschule Technik und Informatik Stateful Session Beans Course Multi Tier Business Applications with Java EE Prof. Dr. Eric Dubuis Berner Fachhochschule Biel Content Characteristics of stateful

More information

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

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

CSC 1214: Object-Oriented Programming

CSC 1214: Object-Oriented Programming CSC 1214: Object-Oriented Programming J. Kizito Makerere University e-mail: jkizito@cis.mak.ac.ug www: http://serval.ug/~jona materials: http://serval.ug/~jona/materials/csc1214 e-learning environment:

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

Practice 2. SOAP & REST

Practice 2. SOAP & REST Enterprise System Integration Practice 2. SOAP & REST Prerequisites Practice 1. MySQL and JPA Introduction JAX-WS stands for Java API for XML Web Services. JAX-WS is a technology for building web services

More information

Object-Relational Mapping is NOT serialization! You can perform queries on each field!

Object-Relational Mapping is NOT serialization! You can perform queries on each field! ORM Object-Relational Mapping is NOT serialization! You can perform queries on each field! Using hibernate stand-alone http://www.hibernatetutorial.com/ Introduction to Entities The Sun Java Data Objects

More information

ClassLevelInterceptorOne

ClassLevelInterceptorOne Interceptors Example interceptors can be browsed at https://github.com/apache/tomee/tree/master/examples/interceptors Help us document this example! Click the blue pencil icon in the upper right to edit

More information

1 of 6 11/08/2011 10:14 AM 1. Introduction 1.1. Project/Component Working Name: SJSAS 9.1, Support for JDBC 4.0 in JDBC RA, RFEs 1.2. Name(s) and e-mail address of Document Author(s)/Supplier: Jagadish

More information

Web Application Development Using JEE, Enterprise JavaBeans and JPA

Web Application Development Using JEE, Enterprise JavaBeans and JPA Web Application Development Using JEE, Enterprise Java and JPA Duration: 35 hours Price: $750 Delivery Option: Attend training via an on-demand, self-paced platform paired with personal instructor facilitation.

More information

Developing Applications with Java EE 6 on WebLogic Server 12c

Developing Applications with Java EE 6 on WebLogic Server 12c Developing Applications with Java EE 6 on WebLogic Server 12c Duration: 5 Days What you will learn The Developing Applications with Java EE 6 on WebLogic Server 12c course teaches you the skills you need

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

Accurate study guides, High passing rate! Testhorse provides update free of charge in one year!

Accurate study guides, High passing rate! Testhorse provides update free of charge in one year! Accurate study guides, High passing rate! Testhorse provides update free of charge in one year! http://www.testhorse.com Exam : 1Z0-850 Title : Java Standard Edition 5 and 6, Certified Associate Exam Version

More information

CS 2334: Programming Structures and Abstractions: Exam 1 October 3, 2016

CS 2334: Programming Structures and Abstractions: Exam 1 October 3, 2016 General instructions: CS 2334: Programming Structures and Abstractions: Exam 1 October 3, 2016 Please wait to open this exam booklet until you are told to do so. This examination booklet has 13 pages.

More information

Simple Entity EJB - xdoclet, MyEclipse, Jboss and PostgreSql, MySql

Simple Entity EJB - xdoclet, MyEclipse, Jboss and PostgreSql, MySql Simple Entity EJB - xdoclet, MyEclipse, Jboss and PostgreSql, MySql Creation and testing of a first Entity Bean using MyEcplise, Jboss and xdoclet. General Author: Sebastian Hennebrüder http://www.laliluna.de/tutorial.html

More information

Chapter 1 Introducing EJB 1. What is Java EE Introduction to EJB...5 Need of EJB...6 Types of Enterprise Beans...7

Chapter 1 Introducing EJB 1. What is Java EE Introduction to EJB...5 Need of EJB...6 Types of Enterprise Beans...7 CONTENTS Chapter 1 Introducing EJB 1 What is Java EE 5...2 Java EE 5 Components... 2 Java EE 5 Clients... 4 Java EE 5 Containers...4 Introduction to EJB...5 Need of EJB...6 Types of Enterprise Beans...7

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

import java.io.*; class OutputExample { public static void main(string[] args) { try{ PrintWriter pw = new PrintWriter

import java.io.*; class OutputExample { public static void main(string[] args) { try{ PrintWriter pw = new PrintWriter class OutputExample try PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter("test1.txt"))); pw.println("outputexample pw.close() catch(ioexception e) System.out.println(" class InputExample

More information

Requirement Document v1.2 WELCOME TO CANLOG.IN. API-Key Help Document. Version SMS Integration Document

Requirement Document v1.2 WELCOME TO CANLOG.IN. API-Key Help Document. Version SMS Integration Document WELCOME TO CANLOG.IN API-Key Help Document Version 1.2 http://www.canlog.in SMS Integration Document Integration 1. Purpose SMS integration with Canlog enables you to notify your customers and agents via

More information

CO Java EE 6: Develop Database Applications with JPA

CO Java EE 6: Develop Database Applications with JPA CO-77746 Java EE 6: Develop Database Applications with JPA Summary Duration 4 Days Audience Database Developers, Java EE Developers Level Professional Technology Java EE 6 Delivery Method Instructor-led

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

CMSC 331 Second Midterm Exam

CMSC 331 Second Midterm Exam 1 20/ 2 80/ 331 First Midterm Exam 11 November 2003 3 20/ 4 40/ 5 10/ CMSC 331 Second Midterm Exam 6 15/ 7 15/ Name: Student ID#: 200/ You will have seventy-five (75) minutes to complete this closed book

More information

EJB 2 - Complex Container Managed Relations (CMP) with JBoss

EJB 2 - Complex Container Managed Relations (CMP) with JBoss EJB 2 - Complex Container Managed Relations (CMP) with JBoss In this tutorial we will show you multiple examples to create CMP relations between EJB. We will use xdoclet to create the interfaces you will

More information

Software Practice 1 - Basic Grammar Basic Syntax Data Type Loop Control Making Decision

Software Practice 1 - Basic Grammar Basic Syntax Data Type Loop Control Making Decision Software Practice 1 - Basic Grammar Basic Syntax Data Type Loop Control Making Decision Prof. Hwansoo Han T.A. Minseop Jeong T.A. Wonseok Choi 1 Java Program //package details public class ClassName {

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

Mysql Create Table Example Primary Key Foreign

Mysql Create Table Example Primary Key Foreign Mysql Create Table Example Primary Key Foreign Key Now, i want to connect this two table by the use of id primary key of girls and want to make it See: How to create a Minimal, Complete, and Verifiable

More information

(A) 99 ** (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

(A) 99 ** (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution Ch 5 Arrays Multiple Choice Test 01. An array is a ** (A) data structure with one, or more, elements of the same type. (B) data structure with LIFO access. (C) data structure, which allows transfer between

More information

Web Application Development Using JEE, Enterprise JavaBeans and JPA

Web Application Development Using JEE, Enterprise JavaBeans and JPA Web Application Development Using JEE, Enterprise Java and JPA Duration: 5 days Price: $2795 *California residents and government employees call for pricing. Discounts: We offer multiple discount options.

More information

"Charting the Course... Mastering EJB 3.0 Applications. Course Summary

Charting the Course... Mastering EJB 3.0 Applications. Course Summary Course Summary Description Our training is technology centric. Although a specific application server product will be used throughout the course, the comprehensive labs and lessons geared towards teaching

More information

Entity LifeCycle Callback Methods Srikanth Technologies Page : 1

Entity LifeCycle Callback Methods Srikanth Technologies Page : 1 Entity LifeCycle Callback Methods Srikanth Technologies Page : 1 Entity LifeCycle Callback methods A method may be designated as a lifecycle callback method to receive notification of entity lifecycle

More information

The Good, the Bad and the Ugly

The Good, the Bad and the Ugly The Good, the Bad and the Ugly 2 years with Java Persistence API Björn Beskow bjorn.beskow@callistaenterprise.se www.callistaenterprise.se Agenda The Good Wow! Transparency! The Bad Not that transparent

More information

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

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

More information

Majustic - Evaluation Test With Answers. Time: 1 hour 30 minutes

Majustic - Evaluation Test With Answers. Time: 1 hour 30 minutes Majustic - Evaluation Test With Answers Time: 1 hour 30 minutes Version 1.0, 04/07/2015 Summary 1. JAVA Questions.............................................................................. 1 1.1. Consider

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

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

The XML PDF Access API for Java Technology (XPAAJ)

The XML PDF Access API for Java Technology (XPAAJ) The XML PDF Access API for Java Technology (XPAAJ) Duane Nickull Senior Technology Evangelist Adobe Systems TS-93260 2007 JavaOne SM Conference Session TS-93260 Agenda Using Java technology to manipulate

More information

Oracle 1z Java Standard Edition 5 Programmer Certified Professional Upgrade Exam. Practice Test. Version: https://certkill.

Oracle 1z Java Standard Edition 5 Programmer Certified Professional Upgrade Exam. Practice Test. Version: https://certkill. Oracle 1z0-854 Java Standard Edition 5 Programmer Certified Professional Upgrade Exam Practice Test Version: 14.20 QUESTION NO: 1 Oracle 1z0-854: Practice Exam 20. public class CreditCard { 21. 22. private

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

Java Persistence API. Patrick Linskey EJB Team Lead BEA Systems Oracle

Java Persistence API. Patrick Linskey EJB Team Lead BEA Systems Oracle Java Persistence API Patrick Linskey EJB Team Lead BEA Systems Oracle plinskey@bea.com Patrick Linskey EJB Team Lead at BEA JPA 1, 2 EG Member Agenda JPA Basics What s New ORM Configuration APIs Queries

More information

Instance Method Development Demo

Instance Method Development Demo Instance Method Development Demo Write a class Person with a constructor that accepts a name and an age as its argument. These values should be stored in the private attributes name and age. Then, write

More information

Department of Civil and Environmental Engineering, Spring Semester, ENCE 688R: Final Exam: 2 Hours, Open Book and Open Notes

Department of Civil and Environmental Engineering, Spring Semester, ENCE 688R: Final Exam: 2 Hours, Open Book and Open Notes Department of Civil and Environmental Engineering, Spring Semester, 2017 ENCE 688R: Final Exam: 2 Hours, Open Book and Open Notes Name : Question Points Score 1 50 2 30 3 20 Total 100 1 Question 1: 50

More information

object/relational persistence What is persistence? 5

object/relational persistence What is persistence? 5 contents foreword to the revised edition xix foreword to the first edition xxi preface to the revised edition xxiii preface to the first edition xxv acknowledgments xxviii about this book xxix about the

More information

Array. Prepared By - Rifat Shahriyar

Array. Prepared By - Rifat Shahriyar Java More Details Array 2 Arrays A group of variables containing values that all have the same type Arrays are fixed length entities In Java, arrays are objects, so they are considered reference types

More information

EJB 2.1 CMP EntityBeans (CMP2)

EJB 2.1 CMP EntityBeans (CMP2) EJB 2.1 CMP EntityBeans (CMP2) Example simple-cmp2 can be browsed at https://github.com/apache/tomee/tree/master/examples/simple-cmp2 OpenEJB, the EJB Container for TomEE and Geronimo, does support all

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

First Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 7 October 2010

First Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 7 October 2010 First Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 7 October 2010 NAME (Printed) NAME (Signed) E-mail Exam Rules Show all your work. Your grade will be

More information

A sample print out is: is is -11 key entered was: w

A sample print out is: is is -11 key entered was: w Lab 9 Lesson 9-2: Exercise 1, 2 and 3: Note: when you run this you may need to maximize the window. The modified buttonhandler is: private static class ButtonListener implements ActionListener public void

More information

Exam Questions 1Z0-895

Exam Questions 1Z0-895 Exam Questions 1Z0-895 Java Platform, Enterprise Edition 6 Enterprise JavaBeans Developer Certified Expert Exam https://www.2passeasy.com/dumps/1z0-895/ QUESTION NO: 1 A developer needs to deliver a large-scale

More information

Accessing databases in Java using JDBC

Accessing databases in Java using JDBC Accessing databases in Java using JDBC Introduction JDBC is an API for Java that allows working with relational databases. JDBC offers the possibility to use SQL statements for DDL and DML statements.

More information

SPRING DECLARATIVE TRANSACTION MANAGEMENT

SPRING DECLARATIVE TRANSACTION MANAGEMENT SPRING DECLARATIVE TRANSACTION MANAGEMENT http://www.tutorialspoint.com/spring/declarative_management.htm Copyright tutorialspoint.com Declarative transaction management approach allows you to manage the

More information

FIFO PAGE REPLACEMENT : import java.io.*; public class FIFO {

FIFO PAGE REPLACEMENT : import java.io.*; public class FIFO { FIFO PAGE REPLACEMENT : import java.io.*; public class FIFO public static void main(string[] args) throws IOException BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int frames,

More information

CS1092: Tutorial Sheet: No 3 Exceptions and Files. Tutor s Guide

CS1092: Tutorial Sheet: No 3 Exceptions and Files. Tutor s Guide CS1092: Tutorial Sheet: No 3 Exceptions and Files Tutor s Guide Preliminary This tutorial sheet requires that you ve read Chapter 15 on Exceptions (CS1081 lectured material), and followed the recent CS1092

More information

CMP relations between Enterprise Java Beans (EJB) eclipse, xdoclet, jboss

CMP relations between Enterprise Java Beans (EJB) eclipse, xdoclet, jboss CMP relations between Enterprise Java Beans (EJB) eclipse, xdoclet, jboss A step by step example showing how to develop CMP relations between EJBs using eclipse, xdoclet and MyEclipse. We use an example

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

(A) 99 (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

(A) 99 (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution Ch 5 Arrays Multiple Choice 01. An array is a (A) (B) (C) (D) data structure with one, or more, elements of the same type. data structure with LIFO access. data structure, which allows transfer between

More information

1- a> [5pts] Create the new table by writing and executing a full SQL DDL statement based on the following schema:

1- a> [5pts] Create the new table by writing and executing a full SQL DDL statement based on the following schema: 1. [20pts] To track the history of financial information changes such as a driver s bank account, you are going to create a table to store the history of all bank account numbers. Once created, this table

More information

Hibernate Overview. By Khader Shaik

Hibernate Overview. By Khader Shaik Hibernate Overview By Khader Shaik 1 Agenda Introduction to ORM Overview of Hibernate Why Hibernate Anatomy of Example Overview of HQL Architecture Overview Comparison with ibatis and JPA 2 Introduction

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