I have been scratching my head for a while and i still have no real solution, this is a strange problem. I have an entity:
Code:
@Entity
@Table(name = "BUYER_EXTERNAL_ID")
public class BuyerExternalId implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "BuyerExternalIdSequence")
@SequenceGenerator(name = "BuyerExternalIdSequence", initialValue = 1, sequenceName = "buyer_external_id_seq")
private Long id;
@Basic(optional = false)
@Column(name = "EXTERNAL_ID", nullable = false, length = 30)
private String externalId;
@Basic(optional = false)
@Enumerated(EnumType.STRING)
@Column(name = "MODULE_NAME", nullable = false, length = 20)
private IdentityModule module;
}
The following code returns a value
Code:
em.createQuery("SELECT bei FROM BuyerExternalId bei WHERE bei.id = 2").getResultList();
But this code doesn't:
Code:
em.createQuery("SELECT bei FROM BuyerExternalId bei WHERE bei.externalId = '102' ").getResultList();
Variations of these queries using named parameters are behaving the same. Only when i try to get the values by externalId property. I am using Derby database, I figured I should log the actual sql send to the server and sure enough its correct and when I run that sql it returns values.