java项目使用jpa_如何使用常见的JPA实体布局Java EE项目?

1) Does the project, containing the common entities, has a persistence.xml file? If so, how does it differ from the one in the other projects?

是.主要区别在于模型项目中的persistence.xml应该定义所有实体,并且web项目中的persistence.xml应该只引用模型项目JAR文件.否则,您将继续在persistence.xml文件中复制entites.

另一个可能的区别是模型项目中的那个应该使用资源本地事务类型,以便从项目内部进行单元测试(例如使用main()方法)非常容易. Web项目中的那些当然应该使用例如数据源. JTA.

2) How exactly are the commonly used entities referenced in the two projects? Do I use the tag in their persistence.xml for reference? And if so, would “lib/MyCommon.jar” be the right way to use, if MyCommin.jar is located in WEB-INF/lib?

是和否.< jar-file>是正确的方法,但你的文件名中有一个拼写错误,文件夹应该省略. lib文件夹通常仅在您拥有EAR并且JAR包含在EAR的lib文件夹中时使用.

MyCommon.jar

3) Does it make any difference if the application is deployed as a WAR or an exploded archive in JBoss 6?

没有.正确设计的Java API不依赖于本地磁盘文件系统,而只依赖于类路径.如果WAR被扩展,它使类路径没有区别.

4) When deployed within eclipse via addition to server runtime and publish, is there anything different from deploying outside eclipse?

从技术上讲,是的.功能上,没有.

5) Is the described way putting common entities in a separate project, creating a JAR and use that JAR in the other project a sensible way to handle the problem of sharing common entity classes or is there a better way?

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值