ahmetalpbalkan/orman — Issue #40: org.orman.mapper.exception.FieldNotFoundException: Could not find property (field)
Author: mulasse
Created: 2011-12-15 14:15:54+00:00
State: open

Hi.
I'm actually using orman on android and I think it's a really convenient orm.

Actually, I got a serious issue. I found a way to fix it temporary but It's not as clean as I would want.
Let me explain:

I got 1 class named Noeud (node) and 1 classe named Equipement (equipment).

Noeud has to ManyToOne relationships. One with itself (on field "parent") and one to Equipement (on field "localisation").

My problem is: when I try to access equipment (by using node.getEquipements()), I got the following error:
org.orman.mapper.exception.FieldNotFoundException: Could not find property (field) `parent` in Equipement.

I checked, double-checked, triple-checked my ManyToOne declarations (code below) but problem is still here).
I have the impression that all ManyToOne associations of one class are sharing their foreign key names.

I solved the problem by renaming "localisation" field on Equipement to "parent" and it seems to work but it could be a problem if I was right about the cause.

```java
class Noeud extends Model {
@OneToMany(onField = Equipement.PROP_LOCALISATION, toType = Equipement.class, load = LoadingPolicy.LAZY)
private EntityList equipements = new EntityList(Noeud.class, Equipement.class, this);

@OneToMany(onField = "parent", toType = Noeud.class, load = LoadingPolicy.LAZY)
private EntityList children = new EntityList(Noeud.class, Noeud.class, this);
}

class Equipement extends Model {
public static final String PROP_LOCALISATION = "localisation"; //actually renamed to "parent"

@ManyToOne(load = LoadingPolicy.LAZY)
private Noeud localisation; //also renamed to "parent"
}
```

Do that sounds familiar to you? Did I miss something in documentation or in my code?

Best regards.