Hello,
I'm using Hibernate OGM with MongoDB.
i have a problem with a class that should have a "join" on two other classes. Basically. If i use the "Utenti" class created in this way:
Code:
@Entity
@Indexed
@Table(name="users")
public class Utenti implements Serializable {
   public Utenti() {
   }
   /**
    *
    */
   private static final long serialVersionUID = 5495044706694401513L;
   @Id
   @GeneratedValue(generator = "uuid")
   @GenericGenerator(name = "uuid", strategy = "uuid2")
   @Type(type = "objectid")
   public String id;
   @Column(name="salt")
   private String salt;
   @Column(name="username")
   private String username;
And use the session factory there are no problem. All works flawlessy. While on my "Report" class that has two link to "Utenti" class i have a problem when i try to use a "where" clause to filter the ID. The class is this one:
Code:
@Entity
@Indexed
@Table(name="reports")
public class Reports implements Serializable {
   public Reports() {
   }
   /**
    *
    */
   private static final long serialVersionUID = 5688689875181900535L;
   @Id
   @GeneratedValue(generator = "uuid")
   @GenericGenerator(name = "uuid", strategy = "uuid2")
   @Type(type = "objectid")
   private String id;
   @Column(name="description")
   private String description;
   @JoinColumn(name="verifiedBy")
   @OneToOne
   //@Column(name="verifiedBy")
   private Utenti verifiedBy;
   @JoinColumn(name="user")
   @OneToOne
   //@Column(name="user")
   private Utenti user;
   @JoinColumn(name="category")
   @OneToOne
   //@Column(name="category")
   private Categories category;
   @Column(name="reportDate")
   private String reportDate;
   @Column(name="reportTime")
   private String reportTime;
   @Column(name="thumbnail")
   private String thumbnail;
   @Column(name="image")
   private String image;
   @Column(name="lat")
   private Double lat;
   @Column(name="lon")
   private Double lon;
   @Column(name="elevation")
   private Integer elevation;
   @Column(name="__v")
   private Integer v;
/* getters an setters */
When i try to filter the reports using this query:
Code:
list = session.createQuery("from Reports where user=:IDUtente").setParameter("IDUtente", new String(userId)).list();
I receive this error:
org.hibernate.property.access.spi.PropertyAccessException: Error accessing field [public java.lang.String it.papersoft.hibernate.Utenti.id] by reflection for persistent property [it.papersoft.hibernate.Utenti#id] : 577d485b55fade0e001759e6
	at org.hibernate.property.access.spi.GetterFieldImpl.get(GetterFieldImpl.java:43)
	at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:223)
...
caused by: java.lang.IllegalArgumentException: Can not set java.lang.String field it.papersoft.hibernate.Utenti.id to java.lang.String
I've tried different way to use the ID and also the class (as you can see the @Column annotation). So.. my question is. What is the correct way to embed an external class with OGM?
Thank you