JDO查询帮助(按配料查找食谱)
|
我需要有关JDO查询的帮助。
我有以下实体:
食谱:
@PersistenceCapable
class Recipe{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long key;
...
@Persistent(mappedBy = \"recipe\")
private List<RecipeIngredient> ingredients
}
配方成分:
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable=\"true\")
class RecipeIngredient implements Serializable {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent
Integer amount
@Persistent
Key unit
@Persistent
Key ingredient
@Persistent
Recipe recipe
成分:
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable=\"true\")
class Ingredient implements Serializable {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent
String name
一个配方可以有几个配方成分,其中包含实际成分,成分数量和单位。
我想按仅包含给定成分而不包含更多成分的成分获取所有食谱。
目前,我这样做:
通过成分名称获取所有成分对象
通过成分键获取所有配方成分对象
按食谱获取所有食谱
检查食谱中的所有食谱成分是否都在之前的食谱成分列表中
如果是这样,则将配方添加到输出列表
我可以通过查询吗?也许与拥有类似的东西?
没有找到相关结果
已邀请:
1 个回复
坛沤疲撑拆