English 中文(简体)
Spring ROO GWT 参考选择
原标题:Spring ROO GWT Select by reference

我与以下实体共同创建了“世界展望组织”项目:事实和项目。

项目内容提及事实。

@RooJavaBean
@RooToString
public class ItemFacture {

    @ManyToOne
    private Facture facture;
...

这是《事实法典》:

@RooJavaBean
@RooToString
@RooEntity
public class Facture {

    private String nom;
    private String type;
}

直到此为止。 我想创建一种习俗,选择包含具体事实的所有项目:

@SuppressWarnings("unchecked")
public static List<ItemFacture> findByFacture(Facture facture) {

    Query q = entityManager().createQuery("SELECT o FROM ItemFacture AS o WHERE o.facture = :facture");
    q.setParameter("facture", facture);

    return q.getResultList();
}

当我试图处决这一寻找者时,这给我留下了这一错误:

服务器(Error):现场“装置”在测试中不存在。 项目设计或没有持久性; nes例外是 j, 持久性:在 com测试中不存在实地“装置”。 项目内容

I created a few custom finders and every one of them worked just fine except this one.

I tried adding @Persistent to the field and @PersistenceCapable(identityType = IdentityType.APPLICATION) to Facture but it still doesn t work.

Anyone know what is the problem?

最佳回答

In AppEngine, references are made with the ID of the referenced object. So event if ItemFacture contain and attribute facture, it s actually stored as factureId.

因此,书写方法是:

@SuppressWarnings("unchecked")
public static List<ItemFacture> findByFacture(Facture facture) {

    Query q = entityManager().createQuery("SELECT o FROM ItemFacture AS o WHERE o.factureId = :facture");
    q.setParameter("facture", facture.getId());

    return q.getResultList();
}
问题回答

i 猜测为什么不做这样的工作,即项目类型不是“Entity”,因此日本邮局没有这方面的想法。 加上“RooEntity roo”的“Facture”类别,产生了一个项目“Factures_Roo_Entity.aj(STS在成套探索器中以违约方式隐藏这些档案),把“Entity annotation on You 项目Facture-class与使该项目成为积极记录的其他部分相联(http://martinfowler.com/eaaCatalog/activeRecord.html)





相关问题
Refresh the UI in gwt

I have created some custom composite widget, which listens to an events (in my case loginEvent). Once the event is caught the state of the widget changes so as the way it should look (in my case I ...

How to create a development/debug and production setup

I recently deployed inadvertently a debug version of our game typrX (typing races at www.typrx.com - try it it s fun). It was quickly corrected but I know it may happen again. After digging on ...

GWT error at runtime: ....style_0 is null

My code works fine in IE 8, but on firefox 3.5, the javascript fails to load. I used firebug to figure out why, and the error I get is (GWT detailed mode) My suspicion is that some style is not ...

GWT s hosted mode not working

I ve been stumped for a while trying to figure out why my GWT demo app isn t working in hosted mode so I went back and downloaded the Google Web Toolkit again, unzipped it and simply went to the ...

How to disable Google Visualizations Tool Tips?

Does anyone know how to disable the tool-tip boxes that popup when a Google Visualizations chart is clicked (Selected)? Following the sample code at Getting Started with Visualizations, the "...

GWT 2 CssResource how to

I have a GWT 1.7 application and I want to upgrade it to GWT 2 Milestone 2. The application uses 2 big external CSS files. In GWT 1.7 I had a public folder and put both the CSS files in the folder and ...

热门标签