not retrieving entity when an attribute of it has value 0.0 [message #892825] |
Fri, 29 June 2012 19:55  |
Eclipse User |
|
|
|
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 19:58] by Moderator
|
|
|
|
Re: not retrieving entity when an attribute of it has value 0.0 [message #893321 is a reply to message #893319] |
Tue, 03 July 2012 10:34  |
Eclipse User |
|
|
|
Sorry, I misread the problem in my last update.
Please turn on logging to finest and try reading in the Iva entity directly using em.find for the entity with pk=3, and try using the refresh query hint on the query bringing in the Producto entity with the null reference. Is the Producto's fechaAlta also set?
Regards,
Chris
|
|
|
Powered by
FUDForum. Page generated in 0.33526 seconds