not retrieving entity when an attribute of it has value 0.0 [message #892825] |
Fri, 29 June 2012 23:55 |
FiruzzZ Mising name Messages: 19 Registered: October 2011 |
Junior Member |
|
|
This is part of the annotations of the @Entity Producto, which contain an Iva (da fuucking problem)
@Basic(optional = false)
@Column(name = "fecha_alta", nullable = false, insertable = false, updatable = false, columnDefinition = "timestamp with time zone NOT NULL DEFAULT now()")
@Temporal(value = TemporalType.TIMESTAMP)
private Date fechaAlta;
@Column(name = "ultima_compra")
@Temporal(value = TemporalType.DATE)
private Date ultimaCompra;
@JoinColumn(name = "iva", referencedColumnName = "id", nullable = false)
@ManyToOne(optional = false)
private Iva iva;
And this is @Entity Iva
public class Iva implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "id", nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Basic(optional = false)
@Column(name = "iva", nullable = false)
private float iva;
the problem is the attribute iva ( I tried with Double, double, Float, float and mapping with SCALE and PRECISION.. nothing worked), WHEN this value is 0.0, the entity is NEVER loaded (retrieved) WITH Producto.
values on db (PostgreSQL) are, also tried changing the data type to double pre, real, numeric(10,2).
id(PK) iva(numeric(4.1)
1; 10.5
2; 21.0
3; 0.0
16; 27.0
when the producto is related to Iva (3, 0.0), this NEVER is loaded, ALWAYS leave the entity null! no matter what.
I tried to make the @Entities mentioned @Cacheable(false), @Cache(Type.FULL), retrieving by CriteriaBuilder
Iva findByProducto(Integer productoID) {
CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
CriteriaQuery<Iva> query = cb.createQuery(Iva.class);
Root<Producto> from = query.from(Producto.class);
query.select(from.get(Producto_.iva)).where(cb.equal(from.get(Producto_.id), productoID));
return getEntityManager().createQuery(query).getSingleResult();
}
Im using Eclipselink 2.2.1
[Updated on: Fri, 29 June 2012 23:58] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02691 seconds