java相关的一切杂言碎语

显示标签为“java”的博文。显示所有博文
显示标签为“java”的博文。显示所有博文

2009年5月10日星期日

hibernate annotion多对多关系示例

实体之间是多对多的关系,如图:


错误的实体代码如下

JAVA 代码:
  1. @ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
  2. @JoinTable(name = "product_packagetype:packageTypes:products")
  3. private java.util.Listimplambition.forxxx.model.PackageType> packageTypes;
  4. /**
  5. * @generated
  6. */
  7. @ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
  8. @JoinTable(name = "product_productcolor:productColors:products")
  9. private java.util.Listimplambition.forxxx.model.ProductColor> productColors;
  10. /**
  11. * @generated
  12. */
  13. @ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
  14. @JoinTable(name = "product_attach:attachs:products")
  15. private java.util.Listimplambition.forxxx.model.Attach> attachs;
这样的代码本身不能正常运行,报错 cannot simultaneously fetch multiple bags。
改成FetchType.LAZY后,报错 WARN [main] 2009-05-10 16:46:18,655 - SQL Error: 1064, SQLState: 42000
ERROR [main] 2009-05-10 16:46:18,655 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':packageTypes:products packagetyp0_ left outer join PackageType packagetyp1_ on ' at line 1



最后只能修改为:
Product实体

JAVA 代码:
  1. /**
  2. * @generated
  3. */
  4. @ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
  5. //@JoinTable(name = "product_packagetype:packageTypes:products")
  6. @JoinTable(name = "product_packagetype", joinColumns = { @JoinColumn(name = "packageTypes") }, inverseJoinColumns = { @JoinColumn(name = "products") })
  7. private java.util.Listimplambition.forxxx.model.PackageType> packageTypes;
  8. /**
  9. * @generated
  10. */
  11. @ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
  12. //@JoinTable(name = "product_productcolor:productColors:products")
  13. @JoinTable(name = "product_productcolor", joinColumns = { @JoinColumn(name = "productColors") }, inverseJoinColumns = { @JoinColumn(name = "products") })
  14. private java.util.Listimplambition.forxxx.model.ProductColor> productColors;
  15. /**
  16. * @generated
  17. */
  18. @ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
  19. //@JoinTable(name = "product_attach:attachs:products")
  20. @JoinTable(name = "product_attach", joinColumns = { @JoinColumn(name = "attachs") }, inverseJoinColumns = { @JoinColumn(name = "products") })
  21. private java.util.Listimplambition.forxxx.model.Attach> attachs;
其他关联实体只列出一个示例,代码如下(注释掉的为studio生成的代码)

JAVA 代码:
  1. /**
  2. * @generated
  3. */
  4. //@ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
  5. @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy="attachs")
  6. private java.util.Listimplambition.forxxx.model.Product> products;

apusic operamasks使用了 w:foreach 迁移到tomcat的问题

aom使用了 w:foreach 迁移到tomcat的问题

如果部署到tomcat的aom应用中使用了 w:foreach,只包含
elite.jar
jsf-api.jar
operamasks-impl.jar
operamasks-options.jar
operamasks-third-party.jar
在一些特殊情况下(w:foreach 绑定的不是一个list对象)是不能运行的,需要加上jstl.jar

uidata.java 方法getDataModel会调用到jstl.jar
复制内容到剪贴板
JAVA 代码:
  1. protected DataModel getDataModel() {
  2. // Return any previously cached DataModel instance
  3. if (this.model != null) {
  4. return (model);
  5. }
  6. // Synthesize a DataModel around our current value if possible
  7. Object current = getValue();
  8. if (current == null) {
  9. setDataModel(new ListDataModel(Collections.EMPTY_LIST));
  10. } else if (current instanceof DataModel) {
  11. setDataModel((DataModel) current);
  12. } else if (current instanceof List) {
  13. setDataModel(new ListDataModel((List) current));
  14. } else if (Object[].class.isAssignableFrom(current.getClass())) {
  15. setDataModel(new ArrayDataModel((Object[]) current));
  16. } else if (current instanceof ResultSet) {
  17. setDataModel(new ResultSetDataModel((ResultSet) current));
  18. } else if (current instanceof Result) {
  19. setDataModel(new ResultDataModel((Result) current));
  20. } else {
  21. setDataModel(new ScalarDataModel(current));
  22. }
  23. return (model);
  24. }

2009年3月31日星期二

JSF 中关于 immediate 属性

对JSF了解的人都知道,JSF的六大生命周期,默认情况下六大生命周期各自的处理逻辑比较合理,但是在现在web交互的模式下(AJAX方式)就会经常出现需要跳过某些生命周期的情况。最常见的就是跳过有效性验证的阶段,JSF使用immediate 属性设为true达到该目的。
具体的处理方式参见以下两图的比对。











我们内部使用Apusic的AOM实现,对于该属性的支持,有一点小小的问题。
aom 的ajax:action使用IOVC绑定相应后台action方法后,即使设置immediate="true"也不会跳过processValidators生命周期,晕呀

2009年3月28日星期六

517fan项目开源

项目517fan开源了,其实也就是找个地方存储自己的代码,呵呵,一个商业应用,还没完成,玩玩。基于aom 和 ejb3开发。
项目地址:http://code.google.com/p/517fan/

2009年3月16日星期一

【转帖】第19届软件奥斯卡奖Jolt大奖已经揭晓

http://www.joltawards.com/winners.html

Jolt Hall of Fame Winner:

  • Compuware DevPartner

Books General

Jolt Winner:

  • Adrenaline Junkies and Template Zombies: Understanding Patterns of Project Behavior by Tom Demarco, Peter Hruschka, Tim Lister, Suzanne Robertson, James Robertson and Steve McMenamin (Dorset House Publishing)
Productivity Winners:
  • Emergent Design: The Evolutionary Nature of Professional Software Development by Scott L. Bain (Addison-Wesley Professional)
  • Intellectual Property and Open Source: A Practical Guide to Protecting Code by Van Lindberg (O'Reilly Media)

Books Technical

Jolt Winner:

  • Real World Haskell by Bryan O'Sullivan, John Goerzen and Don Stewart (O'Reilly Media)
Productivity Winners:
  • High Performance MySQL: Optimization, Backups, Replication, and More by Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy Zawodny, Arjen Lentz and Derek J. Balling (O'Reilly Media)
  • Programming in Scala by Martin Odersky, Lex Spoon and Bill Venners (Artima Press)

Change and Configuration Management Tools

Jolt Winner:

  • OpenMake Meister (OpenMake Software)
Productivity Winners:
  • AccuRev (AccuRev)
  • Change Manager (Embarcadero Technologies)

Database Engines and Data Tools

Jolt Winner:

  • Postgres Plus (EnterpriseDB)
Productivity Winners:
  • Aqua Data Studio (AquaFold)
  • Vertica Analytic Database (Vertica Systems)

Design Tools and Modeling

Jolt Winner:

  • Blueprint Requirements Center (Blueprint Software Systems)
Productivity Winners:
  • RAVEN (Ravenflow)
  • Screen Architect (Screen Architect Ltd. / Catch Ltd.)

Development Environments

Jolt Winner:

  • Altova MissionKit (Altova)
Productivity Winners:
  • JBuilder 2008 (Embarcadero Technologies)
  • ReSharper 4.1 (JetBrains)

Enterprise Tools

Jolt Winner:

  • MindTouch Deki (MindTouch)
Productivity Winners:
  • Agile Platform (OutSystems)
  • Zenoss Core (Zenoss)

Libraries, Frameworks and Components

Jolt Winner:

  • ComponentOne Studio for Silverlight (ComponentOne)
Productivity Winners:
  • Essential Studio Enterprise Edition (Syncfusion)
  • Threading Building Blocks Library 2.1 (Intel)

Mobile and Web Development Tools

Jolt Winner:

  • MITE (Keynote Systems)
Productivity Winners:
  • Adobe Device Central (Adobe Systems)
  • NetBeans IDE (Sun Microsystems)

Project Management Tools

Jolt Winner:

  • Pivotal Tracker (Pivotal Labs)
Productivity Winners:
  • Rally Enterprise (Rally Software Development)
  • ScrumWorks Pro (Danube Technologies)

Security Tools

Jolt Winner:

  • Parasoft Application Security Solution (Parasoft)
Productivity Winners:
  • GuardIT (Arxan)
  • InTrust for Databases (Quest Software)

Testing Tools

Jolt Winner:

  • easyb (easyb.org)
Productivity Winners:
  • Compuware DevPartner Studio (Compuware)
  • SONAR (SonarSource)

Utilities

Jolt Winner:

  • HttpWatch (Simtec Ltd.)
Productivity Winners:
  • DotTrace (JetBrains)
  • JavaRebel (ZeroTurnaround)

pic