Home » Eclipse Projects » EclipseLink » [SOLVED] misunderstanding annotations(Trying to do a very simply ManyToOne annotation but failing)
[SOLVED] misunderstanding annotations [message #941221] |
Fri, 12 October 2012 10:02 |
FiruzzZ Mising name Messages: 19 Registered: October 2011 |
Junior Member |
|
|
I can't figure it out why Eclipselink is expecting a bytea instead of a integer.
@Entity
NotaCrecitoProveedor
//part of the entity
@Basic(optional = false)
@ManyToOne(optional = false)
@JoinColumn(name = "usuario", nullable = false)
private Usuario usuario;
@Basic(optional = false)
@JoinColumn(name = "proveedor", referencedColumnName="id", nullable = false)
@ManyToOne(optional = false)
private Proveedor proveedor;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "notaCreditoProveedor", orphanRemoval = true)
private List<DetalleNotaCreditoProveedor> detalleNotaCreditoProveedorList;
if I execute this JPQL:
return (NotaCreditoProveedor) getEntityManager().createQuery("SELECT o FROM NotaCreditoProveedor o WHERE o.numero = " + numero + " AND o.proveedor.id=" + proveedor.getId()).getSingleResult();
I got this Exception
Exception Description: Invalid query key [id] in expression.
Local Exception Stack:
Exception [EclipseLink-6015] (Eclipse Persistence Services - 2.2.1.v20110722-r9776): org.eclipse.persistence.exceptions.QueryException
Exception Description: Invalid query key [id] in expression.
at org.eclipse.persistence.exceptions.QueryException.invalidQueryKeyInExpression(QueryException.java:658)
at org.eclipse.persistence.internal.expressions.QueryKeyExpression.getQueryKeyOrNull(QueryKeyExpression.java:469)
at org.eclipse.persistence.internal.expressions.QueryKeyExpression.isAttribute(QueryKeyExpression.java:538)
at org.eclipse.persistence.internal.expressions.RelationExpression.isObjectComparison(RelationExpression.java:449)
at org.eclipse.persistence.internal.expressions.RelationExpression.normalize(RelationExpression.java:517)
at org.eclipse.persistence.internal.expressions.CompoundExpression.normalize(CompoundExpression.java:226)
AND i if try to persist a NotaCreditoProveedor throws:
Call: INSERT INTO nota_credito_proveedor (ANULADA, DESACREDITADO, fecha_nota_credito_proveedor, GRAVADO, IMPORTE, impuestos_recuperables, IVA10, IVA21, no_gravado, NUMERO, OBSERVACION, PROVEEDOR, USUARIO, remesa) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
bind => [14 parameters bound]
Query: InsertObjectQuery(NotaCreditoProveedor{id=null, numero=100000001, anulada=false, desacreditado=null, fechaCarga=null, fechaNotaCreditoProveedor=Sun Jan 01 00:00:00 ART 2012, gravado=0.00, importe=0.99, impuestosRecuperables=0.00, iva10=0.00, iva21=0.00, noGravado=0.99, observacion=null, usuario=admin, proveedor=CLIENTECITO, detalleNotaCreditoProveedorList=[DetalleNotaCreditoProveedor{id=null, cantidad=1, precioUnitario=0.99, producto=Producto{id=4, codigo=p00, nombre=p00, stockmaximo=0, stockactual=-1019, stockminimo=0, deposito=null, ubicacion=null, costoCompra=0.0, descripcion=null, updatePrecioVenta=false, precioVenta=0.0, remunerativo=true, fechaAlta=Tue Oct 02 16:35:17 ART 2012, ultimaCompra=null, iva=0.0, marca=MARCA..., rubro=Un Rubro, subrubro=null, idunidadmedida=UNITARIO}}]})
javax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.2.1.v20110722-r9776): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: la columna «proveedor» es de tipo integer pero la expresión es de tipo bytea
Hint: Necesitará reescribir la expresión o aplicarle una conversión de tipo.
Position: 262
Error Code: 0
Call: INSERT INTO nota_credito_proveedor (ANULADA, DESACREDITADO, fecha_nota_credito_proveedor, GRAVADO, IMPORTE, impuestos_recuperables, IVA10, IVA21, no_gravado, NUMERO, OBSERVACION, PROVEEDOR, USUARIO, remesa) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
bind => [14 parameters bound]
Query: InsertObjectQuery(NotaCreditoProveedor{id=null, numero=100000001, anulada=false, desacreditado=null, fechaCarga=null, fechaNotaCreditoProveedor=Sun Jan 01 00:00:00 ART 2012, gravado=0.00, importe=0.99, impuestosRecuperables=0.00, iva10=0.00, iva21=0.00, noGravado=0.99, observacion=null, usuario=admin, proveedor=CLIENTECITO, detalleNotaCreditoProveedorList=[DetalleNotaCreditoProveedor{id=null, cantidad=1, precioUnitario=0.99, producto=Producto{id=4, codigo=p00, nombre=p00, stockmaximo=0, stockactual=-1019, stockminimo=0, deposito=null, ubicacion=null, costoCompra=0.0, descripcion=null, updatePrecioVenta=false, precioVenta=0.0, remunerativo=true, fechaAlta=Tue Oct 02 16:35:17 ART 2012, ultimaCompra=null, iva=0.0, marca=MARCA..., rubro=Un Rubro, subrubro=null, idunidadmedida=UNITARIO}}]})
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:102)
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)
at jpa.controller.AbstractDAO.create(AbstractDAO.java:45)
SOLVED: REMOVED @Basic annotation, but i dont know why it worked
[Updated on: Fri, 12 October 2012 13:44] Report message to a moderator
|
|
| | |
Goto Forum:
Current Time: Fri Apr 26 18:01:24 GMT 2024
Powered by FUDForum. Page generated in 0.03477 seconds
|