Presentation is loading. Please wait.

Presentation is loading. Please wait.

JBoss at Work Databases and JBoss Chapter 4 Jeff Schmitt October 26, 2006.

Similar presentations


Presentation on theme: "JBoss at Work Databases and JBoss Chapter 4 Jeff Schmitt October 26, 2006."— Presentation transcript:

1 JBoss at Work Databases and JBoss Chapter 4 Jeff Schmitt October 26, 2006

2 Persistence Tier ORM – Object Relational Mapping Frees the developer from the perils of converting ResultSets to ArrayLists of DTOs Allows the database to be “transparent” (don’t see it) Therefore we call this the Persistence Tier rather than the Database Tier

3 JDBC According to Sun, not an acronym, but strongly suggests “Java Database Connectivity” An API that loads database drivers, makes connections, create statements, that yield ResultSets upon execution You write the SQL: Insert, Update, Delete, etc. OO purists do not like the thought of dealing with strings and converting to/from objects Violates DRY principle - Don't Repeat Yourself – maintains two representations – Java and SQL

4 OODBMS Object Oriented DBM systems exist Removes the need to marshal and unmarshal objects Unmarshaling, in data binding terms, refers to the conversion of XML documents to Java object instances. OODBMS are not popular, low market share Relational DB systems are widely accepted -- entrenched

5 EJB Entity bean Entity beans – two basic variations –BMP – Bean managed persistence –CMP – Container managed persistence Problem with EJB: –Not a simple POJO: you are forced to deal with a variety of complicated and interdependent classes –Objects tightly coupled with container: you are forced to inherit from EJBObject and implement specific intergfaces

6 JDO Java Data Objects – Sun’s next attempt at a JavaBean-centric persistence API Not an official part of J2EE standard RDBMS vendors slow to support it OODBMS vendors enthusiastically support it Main problem is a complicated API – different from Entity Beans but still complicated

7 Hibernate ORM JBoss Hibernate – one of the most popular of the ORMs JBoss supports it Seems to best represent what the next generation of persistence API’s will look like Meanwhile Sun is working toward a merger of EJB 3.0 and JDO 2.0 – it may resemble Hibernate (we’ll have to see)

8 Case Study Chapter 4: JDBC version Chapter 5: Hibernate version Both chapters use a DAO to hide the details of the persistence layer We create a common interface: CarDAO Method: public List findAll()

9 JDBC Disadvantages Every connection to the db must incur overhead You have to manage the database transaction yourself If you combine DB activity and non-DB such as JMS messages, No way to roll back transactions – this is called a global transaction

10 DataSource advantages JBoss creates a Connection Pool at startup – when you get or close a database connection, you just access an open connection from the pool Container-managed Transaction Context – commits or rolls back automatically Can participate in a global transaction – if you combine DB activity and JMS messages, Transaction Manager can roll back everything

11 JNDI – two level names ENC - Environmental Naming Context – highly recommended naming convention for data sources JNDI name begins with java:comp/env web.xml gives a resource-reference name -- local to the EAR (jdbc/JBossAtWorkDS) jboss-web.xml maps the resource-reference to the global JNDI name Source (java:JBossAtWorkDS) We use XDoclet to generate our web.xml file –See ControllerServlet.java

12 Hypersonic DB Hypersonic completely implemented in Java. Uses JDBC. Ships standard with JBoss A local db where modifications are stored to disk A variation allows hypersonic to run purely in memory (efficient) Can be configured to listen on a TCP port like a database server JCA – J2EE Container Architecture – a standard way for a J2EE container to connect to external datastores See Jaw-ds.xml Place hsqld.jar -- $JBOSS_HOME/server/default/lib – to share across multiple EARs


Download ppt "JBoss at Work Databases and JBoss Chapter 4 Jeff Schmitt October 26, 2006."

Similar presentations


Ads by Google