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:liuyuhui_007@yahoo.com.cn
我的博客:http://hi.baidu.com/vsandjava

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

主页公布的邮箱提供下载

也可到

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

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值