mardi 5 mai 2015

Unable to retrieve data from SQLite database because of table's name.(Hibernate)

I have a tabe in my database with name "Group". This is my model code:

@Entity
@Table(name="Group")
public class Group {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="group_id")
private int id;
@Column(name="name")
private String name;
@Column(name="color")
private String color;

public Group(){
    this(null,null);
}

public Group(String name, String color){
    this.name=name;
    this.color=color;
}

public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getColor() {
    return color;
}

public void setColor(String color) {
    this.color = color;
}

}

I'm trying to retrieve data from database using:

     Session session=mainApp.getSessionFactory().openSession();
     groupList=FXCollections.observableArrayList(session.createCriteria(Group.class).list());
     groupPicker.setItems(groupList);
     session.close();

But it gives me an error(SQL error or missing database (near "Group": syntax error)). I know that it is happening because hibernate generates query similar to this: SELECT * FROM Group. To work properly it should be: SELECT * FROM "Group", but I do not know how to achieve this.

Aucun commentaire:

Enregistrer un commentaire