急!如何在jboss的ejb-jar.xml文件中定义实体bean用到的方法呢?

03-07-02 bluegirl
如何在jboss的ejb-jar.xml文件中定义实体bean用到的方法呢?

例如findbyId。

要不要写sql语句。哪位dx知道如何写?

例如:

<container-transaction>

<method>

<ejb-name>ProtonAccount</ejb-name>

<method-intf>Home</method-intf>

<method-name>findByID</method-name>

</method>

<trans-attribute>Required</trans-attribute>

</container-transaction>

我的sql怎么加?

谢谢!

bluegirl
2003-07-02 16:45
配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd">
<ejb-jar>       
	<display-name>bothjboss</display-name>
	<enterprise-beans>
	         <session >
			<ejb-name>Ledger1</ejb-name>
			<home>com.bank.Ledger1Home</home>
			<remote>com.bank.Ledger1</remote>
			<ejb-class>com.bank.Ledger1Bean</ejb-class>
			<session-type>Stateless</session-type>
			<transaction-type>Bean</transaction-type>
		</session>
		<session >
			<ejb-name>Transfer</ejb-name>
			<home>com.bank.TransferHome</home>
			<remote>com.bank.Transfer</remote>
			<ejb-class>com.bank.TransferBean</ejb-class>
			<session-type>Stateless</session-type>
			<transaction-type>Bean</transaction-type>
		</session>
		
		<entity >
			<ejb-name>ProtonAccount</ejb-name>
			<home>com.bank.ProtonAccountHome</home>
			<remote>com.bank.ProtonAccount</remote>
			<ejb-class>com.bank.ProtonAccountBean</ejb-class>
			<persistence-type>Container</persistence-type>
			<prim-key-class>java.lang.String</prim-key-class>
                        <reentrant>False</reentrant>
			<cmp-field id="CMPAttribute_5">
				<field-name>account_number</field-name>
			</cmp-field>
			<cmp-field id="CMPAttribute_6">
				<field-name>customer_name</field-name>
			</cmp-field>
			<cmp-field id="CMPAttribute_7">
				<field-name>balance</field-name>
			</cmp-field>
			<primkey-field>account_number</primkey-field>
            <resource-ref>
                <res-ref-name>jdbc/DB2DS</res-ref-name>
                <res-type>javax.sql.DataSource</res-type>
                <res-auth>Container</res-auth>
            </resource-ref>
		</entity>
	</enterprise-beans>
	<assembly-descriptor>
	
    <container-transaction>
      <method>
      	<ejb-name>ProtonAccount</ejb-name>
      	<method-intf>Home</method-intf>
      	<method-name>create</method-name>
      </method>
      <trans-attribute>Required</trans-attribute>
    </container-transaction>
    <container-transaction>
      <method>
      	<ejb-name>ProtonAccount</ejb-name>
      	<method-intf>Home</method-intf>
      	<method-name>findAllAcounts</method-name>
      </method>
      <trans-attribute>Required</trans-attribute>
    </container-transaction>
    <container-transaction>
      <method>
      	<ejb-name>ProtonAccount</ejb-name>
      	<method-intf>Home</method-intf>
      	<method-name>findByID</method-name>
      </method>
      <trans-attribute>Required</trans-attribute>
    </container-transaction>
	</assembly-descriptor>
     <ejb-client-jar />
</ejb-jar>
<p>

猜你喜欢