You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Charlie Kelly <Ch...@CharlieKelly.com> on 2006/12/01 17:06:28 UTC
Derby with JBoss ?
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
Re: Configuration files for JBoss using Derby
Posted by "Jean T. Anderson" <jt...@bristowhill.com>.
Charlie Kelly wrote:
...
> 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).
...
Thanks for posting this information, Charlie! I added a link to this
post to the http://wiki.apache.org/db-derby/WorkingWithDerby wiki page.
-jean
Configuration files for JBoss using Derby
Posted by Charlie Kelly <Ch...@CharlieKelly.com>.
Hi Derby Community,
I've found that Derby works create with both server and client side
applications.
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>
<persistence-unit name="erp">
<jta-data-source>java:/DerbyDS</jta-data-source>
<properties>
</properties>
</persistence-unit>
</persistence>
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 1.1.4.1 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
-->
<jndi-name>DerbyDS</jndi-name>
- <!--
for in-process persistent db, saved when jboss stops. The
org.jboss.jdbc.DerbyDatabase mbean is necessary for properly db shutdown
-->
<connection-url>jdbc:derby:C:\Amp_Development_01\derbyDatabase\erp00;create=true</connection-url>
- <!--
The driver class
-->
<driver-class>org.apache.derby.jdbc.EmbeddedDriver</driver-class>
- <!--
The login and password
-->
- <!--
The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use
-->
<min-pool-size>5</min-pool-size>
- <!--
The maximum connections in a pool/sub-pool
-->
<max-pool-size>20</max-pool-size>
- <!--
The time before an unused connection is destroyed
-->
<idle-timeout-minutes>5</idle-timeout-minutes>
- <!--
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
-->
</local-tx-datasource>
</datasources
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"?>
<ejb-jar
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
version="3.0">
<enterprise-beans>
<session>
<ejb-name>DatabaseBuilderBean</ejb-name>
<ejb-class>com.charleskelly.amp.database_builder.DatabaseBuilderBean</ejb-class>
<env-entry>
<env-entry-name>schemaJarFileName</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>C:\Amp_Development_01\jboss\server\default\deploy\ErpSchema.jar</env-entry-value>
</env-entry>
</session>
</enterprise-beans>
</ejb-jar>
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 =
NOT_INITIALIZED;
@PersistenceUnit(unitName="erp") private EntityManagerFactory
erpEntityManagerFactory;
@PersistenceContext(unitName="erp") private EntityManager
erpEntityManager;
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
Charlie
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
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>
>
>
Re: Derby with JBoss ?
Posted by David Van Couvering <da...@vancouvering.com>.
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
>>>
>>>
>>>
>>
>>
>>
>
>
>
Re: Derby with JBoss ?
Posted by Charlie Kelly <Ch...@CharlieKelly.com>.
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
>>
>>
>>
>
>
>
Re: Derby with JBoss ?
Posted by David Van Couvering <da...@vancouvering.com>.
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
>
>
>