DataSource and Entity Grief...
antispam Jun 28, 2002 11:23 AMI have a database setup with data already in it.
I am migrating our DB objects over to CMP 2.0
Entity beans. I have started the port and have
a stateless session bean accessing the entity beans.
I also am having to mix models (ours and CMP) until
the migration is complete.
In my session beans I use one our objects to query
a list of values from our tables. However, the
queries from my objects don't seem to be going
to our DB but to the Container.
I have our database objects pointing to the same
connection pool as our Entity beans.
When my session bean invokes our database object,
the session beans don't
access the database but the container's cache.
I have a table in our DB called "data_portSpeed".
My database object calls "select * from
data_portSpeed". However, it first blows up stating
that the table "DATA_PORTSPEED" doesn't exist.
Also, I noticed that a new table was created in my DB called DataPortSpeed.
What is the tag that maps the Entity Bean to the table? Here's my xml:
ejb.xml
.... XML Header ....
<ejb-name>DataPortSpeed</ejb-name>
<local-home>com.broadsource.ejb.DataPortSpeedHome</local-home>
com.broadsource.ejb.DataPortSpeed
<ejb-class>com.broadsource.ejb.DataPortSpeedBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
False
<abstract-schema-name>data_portSpeed</abstract-schema-name>
<cmp-field><field-name>id</field-name></cmp-field>
<cmp-field><field-name>portSpeedName</field-name></cmp-field>
<primkey-field>id</primkey-field>
<resource-ref>
<res-ref-name>jdbc/SQLMainDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<ejb-name>DataPortSpeedHelper</ejb-name>
com.broadsource.ejb.DataPortSpeedHelperHome
com.broadsource.ejb.DataPortSpeedHelper
<ejb-class>com.broadsource.ejb.DataPortSpeedHelperBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-local-ref>
<ejb-ref-name>ejb/DataPortSpeedHome</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<ejb-link>DataPortSpeed</ejb-link>
<local-home>com.broadsource.ejb.DataPortSpeedHome</local-home>
com.broadsource.ejb.DataPortSpeed
</ejb-local-ref>
<resource-ref>
<res-ref-name>jdbc/SQLMainDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
... rest of my ejb-jar.xml ...
.... jboss.xml.....
<ejb-name>DataPortSpeed</ejb-name>
<jndi-name>ejb/DataPortSpeedHome</jndi-name>
<resource-ref>
<res-ref-name>jdbc/SQLMainDB</res-ref-name>
<resource-name>SQLMainDB</resource-name>
</resource-ref>
<ejb-name>DataPortSpeedHelper</ejb-name>
<jndi-name>ejb/DataPortSpeedHelperHome</jndi-name>
<resource-ref>
<res-ref-name>jdbc/SQLMainDB</res-ref-name>
<resource-name>SQLMainDB</resource-name>
</resource-ref>
... rest of jboss.xml
I am using JBoss 3.0 with the MS SQL JDBC driver from Microsoft.
My questions are
1.) How can I create Entities with already populated data?
2.) How can I get it so that my existing DB Objects query against the DB
and not the Container.
3.) What tag in the XML tells the Container what table to map to?