Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » not retrieving entity when an attribute of it has value 0.0
icon4.gif  not retrieving entity when an attribute of it has value 0.0 [message #892825] Fri, 29 June 2012 23:55 Go to next message
FiruzzZ Mising name is currently offline FiruzzZ Mising nameFriend
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

Re: not retrieving entity when an attribute of it has value 0.0 [message #893319 is a reply to message #892825] Tue, 03 July 2012 14:26 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Hello,

By default, EclipseLink interprets '0' values as null for primary keys. This is configurable using the "eclipselink.id-validation" persistence property as described here:

http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Entities/Ids/Id

Best Regards,
Chris
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 14:34 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
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
Previous Topic:Fetching entities with their lazy Lob fields using a query?
Next Topic:How to prevent EL from creating Reference ReadAllQuery
Goto Forum:
  


Current Time: Thu Apr 25 02:18:19 GMT 2024

Powered by FUDForum. Page generated in 0.02289 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top