<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd"> <ejb-jar id="ejb-jar_ID"> <display-name>emp_back</display-name> <enterprise-beans> <entity> <display-name>user</display-name> <ejb-name>UserInfo</ejb-name> <home>com.employee.login.UserHome</home> <remote>com.employee.login.User</remote> <ejb-class>com.employee.login.UserBean</ejb-class> <persistence-type>Container</persistence-type> <prim-key-class>java.lang.String</prim-key-class> <reentrant>false</reentrant> <abstract-schema-name>UserInfo</abstract-schema-name> <cmp-field><field-name>id</field-name></cmp-field> <cmp-field><field-name>name</field-name></cmp-field> <cmp-field><field-name>password</field-name></cmp-field> <cmp-field><field-name>relname</field-name></cmp-field> <cmp-field><field-name>sex</field-name></cmp-field> <cmp-field><field-name>age</field-name></cmp-field> <primkey-field>id</primkey-field> <query> <query-method> <method-name>findByNamePassword</method-name> <method-params> <method-param>java.lang.String</method-param> <method-param>java.lang.String</method-param> </method-params> </query-method> <ejb-ql> <![CDATA[select Object(user) from UserInfo user where user.name = ?1 and user.password = ?2]]> </ejb-ql> </query> </entity> </enterprise-beans> </ejb-jar>
上面<ejb-name>用于指定数据库表名称。
默认採用上述方法进行处理。可是依据不同server,一般都会有一个特定的配置文件进行指定
如glassfish採用的是 sun-cmp-mappings.xml文件进行配置