java - Bidirectional OneToMany/ManyToOne mapping in OpenJPA JPQL problem -


i have 2 classes bidrectional relationship:

@entity @access(accesstype.field) @table(name="room") public class room {     @id     @generatedvalue     @column(name="room_id_pk", updatable=false, nullable=false)     private int id;     @column(name="name", nullable=false, unique=true)     private string name;     @onetomany(mappedby="room", cascade={cascadetype.all})     private final set<wall> walls;     ... }  @entity @access(accesstype.field) @table(name="walls") public class wall {     @id     @generatedvalue     @column(name="wall_id_pk", updatable=false, nullable=false)     private int id;     @column(name="name", nullable=false, unique=true)     private string name;     @manytoone     @joincolumn(name="room_id_fk", referencedcolumnname="room_id_pk")     private room room;     ... } 

i'm running mysql -- looks sane set of tables generated:

rooms: int room_id_pk, varchar name walls: int wall_id_pk, varchar name, int room_id_fk 

however when execute jpql query

select w wall w, room r w member of r.walls , r = :room 

i error:

propertyaccessexception 1: org.springframework.beans.methodinvocationexception: property 'wall' threw exception; nested exception <openjpa-2.0.1-r422266:989424 nonfatal user error> org.apache.openjpa.persistence.argumentexception:an error occurred while parsing query filter "select w wall w, room r w member of r.walls , r = :room". error message: no field named "walls" in "room". did mean "name"? expected 1 of available field names in "mypackage.room": "[id, name]". 

for reason 'walls' not being seen field of room class. code works in hibernate -- i'm attempting migrate openjpa came across error. i've confirmed both classes defined in persistence.xml.

i not 100% sure if cause, making walls variable final looks strange me.

so remove final marker, , try again.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -