I've added a JPA query to my application which does a simple join:
SELECT lic.productId, COUNT(lic) FROM License lic, SalesOrder o WHERE lic.salesOrder=o.id AND o.countryCode LIKE :countryCode GROUP BY lic.productId

where SalesOrder and License are defined

@Entity(name = "SalesOrder")
@Table(name = "SALESORDER")
public class SalesOrder implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "ORDERID")
    private long id;

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "salesOrder")
    private Collection<License> licenses = new ArrayList<License>();
.
.
.
}

@Entity
@Table(name="LICENSE")
public class License implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "ID")
    private Long id;

    @ManyToOne()
    @JoinColumn(name="SALESORDER")
    private SalesOrder salesOrder;
.
.
.
}

but this fails with the error:
Filter invalid. Cannot compare field salesOrder of type softbiz.SalesOrder to field id of type long. Numeric comparisons must be between numeric types only. To enable such comparisons for backwards-compatibility, add "QuotedNumbersInQueries=true" to the org.apache.openjpa.Compatibility setting in your configuration.

This query works fine with GlassFish+TopLink, but fails under Geroniomo 2.1.3 + OpenJPA 1.0.3. Both are running under Java 1.5.0_16 (32-bit) running under Mac OS 10.5.5 on a 64-bit intel processor (Core2).


The page
http://openjpa.apache.org/builds/1.0.2/apache-openjpa-1.0.2/docs/manual/ref_guide_dbsetup_sql92.html
seems to be addressing something different from the error message, which is confusing.


What is the best way to do the join? If I indeed need to set "QuotedNumbersInQueries=true", where should I do this in the Geronimo +OpenJPA configuration files? I've grepped for "org.apache.openjpa.Compatibility" and can't find it.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to