Hi,
I created a table in MySQL:
'object_label' with columns 'id' and 'name'.
I inserted values to this table.
In java I created new class -'ObjectLabel':
Code:
@Entity
@Table(name = "object_label")
public class ObjectLabel implements Serializable {
private static final long serialVersionUID = 3475812350796110403L;
private String name;
public Long getId() { return id; }
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(precision = 10, unique = true, nullable = false, updatable = false)
public Long getId() {
return id;
}
public void setId( Long id ) {
this.id = id;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
}
in hibernate.cfg.xml defined:
Code:
<mapping class="com.myCompany.model.ObjectLabel" />
I whant to get the valuse from the table,
I definded service :
Code:
@SuppressWarnings( "unchecked" )
@Transactional( readOnly = true, propagation = Propagation.SUPPORTS )
public Collection<T> findAll() {
Session session = getSessionFactory().getCurrentSession();
return
session.createCriteria( persistentClass
).setResultTransformer( Criteria.DISTINCT_ROOT_ENTITY
).list();
}
I gets empty list.
in the database
Code:
select * from 'object_label'
return the values)
what the problem in my code?
Thanks!