EJB3(中文版) 第七集 Secondary Tables

EJB规范允许映射一个实体到多个表,你可以通过使用@SecondaryTable批注.
Customer组件映射它的地址属性到一个分开的ADDRESS表.首先定义第二个表.
@Entity
@Table(name = "CUSTOMER")
@SecondaryTable(name = "EMBEDDED_ADDRESS", join = {@JoinColumn(name = "ADDRESS_ID")})
public class Customer implements java.io.Serializable
{}
第二个表的@JoinColumn注释name属性必需与Customer的主键匹配.
@Column.


@Column(name = "STREET", secondaryTable = "EMBEDDED_ADDRESS")
public String getStreet()
{
return street;
}

注意:在JBoss内置数据库中不会出现这样的警告
MySQL中会出现
18:55:15,125 INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no
JNDI name configured
18:55:15,140 INFO [SchemaExport] Running hbm2ddl schema export
18:55:15,140 INFO [SchemaExport] exporting generated schema to database
18:55:15,171 WARN [JDBCExceptionReporter] SQL Warning: 1051, SQLState: 42S02
18:55:15,187 WARN [JDBCExceptionReporter] Unknown table 'customer'
18:55:15,187 WARN [JDBCExceptionReporter] SQL Warning: 1051, SQLState: 42S02
18:55:15,187 WARN [JDBCExceptionReporter] Unknown table 'customer'
18:55:15,187 WARN [JDBCExceptionReporter] SQL Warning: 1051, SQLState: 42S02
18:55:15,187 WARN [JDBCExceptionReporter] Unknown table 'embedded_address'
18:55:15,281 WARN [JDBCExceptionReporter] SQL Warning: 1051, SQLState: 42S02
18:55:15,281 WARN [JDBCExceptionReporter] Unknown table 'customer'
18:55:15,281 WARN [JDBCExceptionReporter] SQL Warning: 1051, SQLState: 42S02
18:55:15,281 WARN [JDBCExceptionReporter] Unknown table 'embedded_address'
18:55:15,500 WARN [JDBCExceptionReporter] SQL Warning: 1051, SQLState: 42S02
18:55:15,500 WARN [JDBCExceptionReporter] Unknown table 'customer'
18:55:15,500 WARN [JDBCExceptionReporter] SQL Warning: 1051, SQLState: 42S02
18:55:15,500 WARN [JDBCExceptionReporter] Unknown table 'embedded_address'
18:55:15,718 WARN [JDBCExceptionReporter] SQL Warning: 1051, SQLState: 42S02
18:55:15,718 WARN [JDBCExceptionReporter] Unknown table 'customer'
18:55:15,718 WARN [JDBCExceptionReporter] SQL Warning: 1051, SQLState: 42S02
18:55:15,734 WARN [JDBCExceptionReporter] Unknown table 'embedded_address'
18:55:15,734 INFO [SchemaExport] schema export complete
18:55:15,750 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.fa
ctory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.p
kgs=org.jboss.naming:org.jnp.interfaces}

我的联系方式:
QQ:495585885
Email:[email protected]
我的博客:http://hi.baidu.com/vsandjava

如果有谁将警告去掉了,麻烦回复一下,我就不再找了.

主页公布的邮箱提供下载

也可到

http://hi.baidu.com/vsandjava/blog/item/3fac221ff2f394c8a686697f.html

你可能感兴趣的:(sql,mysql,jboss,qq,ejb)