db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charlie Kelly <Char...@CharlieKelly.com>
Subject Configuration files for JBoss using Derby
Date Mon, 04 Dec 2006 14:39:31 GMT
Hi Derby Community,

I've found that Derby works create with both server and client side 
I use Hibernate for object-relational mapping.  Our client side 
applications are Eclipse rich client platform programs.
Our server side applications are enterprise java beans 3.0 (EJB3) 
running under a JBoss application server.
We use the same annotated plain old java objects (POJOs) on the server 
side and the client side (eliminating the need for data transfer objects).

The three xml files listed below may help you avoid configuration 
management problems when you start using Derby with JBoss (the default 
persistence provider in JBoss is hsql).

The first file is persistence.xml (include this file in the META-INF 
directory of the jar file that contains your bean)
<?xml version="1.0" encoding="UTF-8"?>
   <persistence-unit name="erp">

The only thing you need to change is the persistence-unit name ("erp" in 
this example).

The second file is erp-derby-ds.xml (you can rename this to any filename 
that ends in -ds.xml; place the file in the deploy directory of your 
JBoss server)
  <?xml version="1.0" encoding="UTF-8" ?>
- <!--

 The Derby embedded database JCA connection factory config
$Id: derby-ds.xml,v 2004/11/03 13:28:39 loubyansky Exp $ 

- <#> <datasources>
- <#> <local-tx-datasource>
- <!--

 The jndi name of the DataSource, it is prefixed with java:/ 

- <!--

 Datasources are not available outside the virtual machine 

- <!--

 for in-process persistent db, saved when jboss stops. The
      org.jboss.jdbc.DerbyDatabase mbean is necessary for properly db shutdown 


- <!--

 The driver class 

- <!--

 The login and password 

- <!--

 The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use 

- <!--

 The maximum connections in a pool/sub-pool 

- <!--

 The time before an unused connection is destroyed 

- <!--

 Whether to check all statements are closed when the connection is returned to the pool,
           this is a debugging feature that should be turned off in production 

  <track-statements />
- <!--

 This mbean can be used when using in process persistent derby 


Although not strictly necessary, you can create an ejb-jar.xml file that 
can be used at deployment time to pass parameters to your bean (the file 
is place in the META-INF directory of the jar file that contains your bean).
<?xml version="1.0"?>


I've found the "schemaJarFileName" to be helpful: it contains the ddl 
for erp Derby database.  I use a bean to create tables and a second bean 
to install "initialization data" into the tables.

The following definitions within the bean(s) provide access to the 
attributes defined above:
private static final String NOT_INITIALIZED = "not initialized";
@Resource (name="schemaJarFileName") private String schemaJarFileName = 
    @PersistenceUnit(unitName="erp") private EntityManagerFactory 
    @PersistenceContext(unitName="erp") private EntityManager 

I hope this is helpful for the community.
A good source of additional information is "Enterprise JavaBeans 3.0" by 
Bill Burke; O'Reilly 2006


David Van Couvering wrote:

> I think that would be a great thing to post, both on this list and 
> perhaps on the JBoss forum, if such a thing exists...
> David
> Charlie Kelly wrote:
>> Hi David,
>> Yes, the EntitytManager is based on Hibernate; and Derby and 
>> Hibernate work well together.
>> There is an error in the xml files that are released with the binary 
>> version of JBoss.
>> I solved the problem today.  I'll post it if anyone wants it.
>> Thanks
>> Charlie
>> David Van Couvering wrote:
>>> I think the JBoss Entity Manager is Hibernate, isn't it?  I am 
>>> pretty sure Derby works with that...
>>> David
>>> Charlie Kelly wrote:
>>>> Has anybody used Derby with JBoss (and perhaps EJB3 Entity Manager)?
>>>> I'm using JBoss 4.0.4
>>>> If yes, how did you configure your xml files?
>>>> Thanks
>>>> Charlie

View raw message