Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Strage error with typedQuery

The error seems to indicate that the Enum is being passed directly to the
database without being converted.

Setting, "eclipselink.logging.parameters"="true" in your persistence.xml
will help debug, then it will print the parameters.

I'm not sure how the value could be missed being converted.  What type is
used for the column in the table?



Arcangel wrote:
> 
> Hello.
> 
> I'm having some troubles with a query:
> ----------------
> CriteriaQuery<DetalleDevolucion> criteriaQuery = 
> cb.createQuery(DetalleDevolucion.class);
> 
> Root<DetalleDevolucion> from =
> criteriaQuery.from(DetalleDevolucion.class);
> 		
> Predicate predicate = cb.equal(from.get(DetalleDevolucion_.tipoSorteo), 
> tipoSorteo);
> 
> predicate = cb.and(predicate,
> cb.equal(from.get(DetalleDevolucion_.noSorteo), 
> Integer.valueOf(noSorteo)));
> 
> predicate = cb.and(predicate, 
> cb.equal(from.get(DetalleDevolucion_.tipoDevolucion), 
> TipoDevolucion.valueOf(tipoDevolucion)));
> 		
> criteriaQuery.where(predicate);
> 		
> TypedQuery<DetalleDevolucion> typedQuery = em.createQuery(criteriaQuery);
> return typedQuery.getResultList();
> ------------------
> When I do that I obtain:
> ----------------
> Exception [EclipseLink-4002] (Eclipse Persistence Services -
> 2.2.0.v20110202-
> r8913): org.eclipse.persistence.exceptions.DatabaseException
> Internal Exception: java.sql.SQLException: El tipo no está soportado.
> Error Code: 20000
> Call: SELECT NOSERIE, NOBILLETE, NOSORTEO, SIGNO, TIPOSORTEO, NOFRACCION, 
> AUDITUSER, CONSECUTIVO, DEVOLUCION, FRACCIONES, NOCORTE, OBSERVACIONES, 
> TIPODEVOLUCION, VERSION FROM DetallesDevolucionAcum WHERE (((((TIPOSORTEO
> = ?) 
> AND (NOSORTEO = ?)) AND (TIPODEVOLUCION = ?)) AND (NOCORTE = ?)) AND 
> (FRACCIONES = ?))
> bind => [5 parameters bound]
> --------------
> 
> if I comment this part: 
> ------------
> predicate = cb.and(predicate, 
> cb.equal(from.get(DetalleDevolucion_.tipoDevolucion), 
> TipoDevolucion.valueOf(tipoDevolucion)));
> ----------
> The query works fine.
> 
> 
> My entity is declared this way:
> -----------------
> @Entity
> @Table(name="DetallesDevoluciones")
> @IdClass(FraccionPK.class)
> @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
> public class DetalleDevolucion extends Model {
> 
> 	@Id
> 	@NotEmpty(message="El tipo de sorteo no puede estar vacio.")
> 	@Pattern(regexp="[A-Z]{2}", message="El tipo de sorteo deben ser 2 
> letras mayúsculas.")
> 	private String tipoSorteo;
> 	
> 	@Id
> 	@NotNull(message="El consecutivo no puede estar vacio.")
> 	@Range(min=0, max=9999, message="El valor del no de Sorteo debe estar 
> entre 0 y 9999")
> 	private Integer noSorteo;
> 	
> 	@NotNull(message="El consecutivo no puede estar vacio.")
> 	@Range(min=0, max=99, message="El valor del consecutivo debe estar 
> entre 0 y 99")
> 	private Integer consecutivo;
> 
> 	@NotNull(message="La cantidad de devolución no puede estar vacia.")
> 	@Digits(integer=14, fraction=2, message="El devolución inútil es mayor 
> al máximo predeterminado")
> 	@Column(precision = 14, scale = 2)
> 	private BigDecimal devolucion;
> 
> 	@NotNull(message="Las fracciones no pueden estar vacias.")
> 	private Integer fracciones;
> 	
> 	@Id
> 	@NotNull(message="El No de Billete no puede estar vacio.")
> 	@Range(min=0, max=9999999, message="El valor del no de billete debe 
> estar entre 0 y 9999999")
> 	private Integer noBillete;
> 	
> 	@Id
> 	@NotNull(message="El signo no puede estar vacio.")
> 	@Range(min=0, max=12, message="El valor del signo debe estar entre 0 y 
> 12")
> 	private Integer signo;
> 	
> 	@Id
> 	@NotNull(message="La serie no puede estar vacia.")
> 	@Range(min=1, max=9, message="El no de serie debe estar entre 1 y 9")
> 	private Integer noSerie;
> 	
> 	@Id
> 	@NotNull(message="El no de fracción no puede estar vacio.")
> 	@Range(min=-99, max=99, message="El valor del no de fracción debe 
> estar entre 0 y 99")
> 	private Integer noFraccion;
> 	
> 	@NotNull(message="El no de corte no puede estar vacio.")
> 	@Index
> 	@Column(name="NOCORTE")
> 	private Integer noCorte;
> 	
> 	private String observaciones;
> 	
> 	@Enumerated(EnumType.STRING)
> 	@NotNull(message="El tipo de devolución no puede estar vacio.")
> 	@Index
> 	@Column(name="TIPODEVOLUCION")
> 	private TipoDevolucion tipoDevolucion;
> 
> ...
> }
> ------------
> And I have a child entity:
> --------------
> @Entity
> @Table(name="DetallesDevolucionAcum")
> public class DetalleDevolucionAcum extends DetalleDevolucion{
> 
> 	private static final long serialVersionUID = 1893358673129186997L;
> 
> }
> ---------------
> 
> Any Ideas?
> 
> Thanks for your help.
> -- 
> I.S.C. José Arcángel Salazar Delgado
> Gerente de I+D
> Tel. oficina: 229-9-27-54-78
> 
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
Blog:  http://java-persistence-performance.blogspot.com/ Java Persistence
Performance 
-- 
View this message in context: http://old.nabble.com/Strage-error-with-typedQuery-tp32374726p32381798.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top