I have the following three tables:
Code:
CREATE TABLE "ECS_IMPLEMENTATIONS" (
"IMPLEMENTATION_ID" NUMBER(10,0),
...
);
CREATE TABLE "ECS_REFLIST_VALUES" (
"LIST_ITEM_ID" NUMBER(10,0),
"LIST_NAME" VARCHAR2(30 BYTE),
"LIST_VALUE" VARCHAR2(30 BYTE)
);
CREATE TABLE "ECS_IMPL_REFLIST_VALUES" (
"IMPLEMENTATION_ID" NUMBER(10,0),
"LIST_ITEM_ID" NUMBER(10,0),
...
);
As you can see the ECS_IMPL_REFLIST_VALUES is many-to-many association table between both ECS_IMPLEMENTATIONS and ECS_REFLIST_VALUES.
Then I have defined these two entities:
Code:
@Entity
@Table(name = "ECS_IMPLEMENTATIONS")
public class ECSImplementation {
...
@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY)
@JoinTable(name = "ECS_IMPL_REFLIST_VALUES",
joinColumns = @JoinColumn(name = "IMPLEMENTATION_ID"),
inverseJoinColumns = @JoinColumn(name = "LIST_ITEM_ID")
)
@Where(clause = "LIST_NAME = 'ORDER_PAYMENT_TYPES")
@MapKey(name = "listValue")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Map<String, ECSReflistValue> deliveryTypes;
...
}
@Entity
@Table (name = "ECS_REFLIST_VALUES")
public class ECSReflistValue {
@Id
@Column (name = "LIST_ITEM_ID")
private Long id;
@Column (name = "LIST_NAME")
private String listName;
@Column (name = "LIST_VALUE")
private String listValue;
...
}
Now when I try to acess ECSImplementation.deliveryTypes, Hibernate generates the query
Code:
select paymenttyp0_.IMPLEMENTATION_ID as IMPLEMEN1_1_, paymenttyp0_.LIST_ITEM_ID as LIST2_1_, (select a5.LIST_VALUE from ECS_REFLIST_VALUES as a5 where a5.LIST_ITEM_ID=paymenttyp0_.LIST_ITEM_ID) as formula2_1_, ecsreflist1_.LIST_ITEM_ID as LIST1_35_0_, ecsreflist1_.TEXT_ID as TEXT2_35_0_, ecsreflist1_.LIST_NAME as LIST3_35_0_, ecsreflist1_.LIST_VALUE as LIST4_35_0_ from ECS_IMPL_REFLIST_VALUES paymenttyp0_ left outer join ECS_REFLIST_VALUES ecsreflist1_ on paymenttyp0_.LIST_ITEM_ID=ecsreflist1_.LIST_ITEM_ID where ( ecsreflist1_.LIST_NAME = 'ORDER_PAYMENT_TYPES' ) and paymenttyp0_.IMPLEMENTATION_ID=?
which fails with the exception
java.sql.SQLException: ORA-00907: missing right parenthesis.
Can anyone sense where is a problem and why does Hibernate generate wrong SQL? Thank you for any info.
--
Hibernate settings:Code:
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.connection.autocommit">false</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
Hibernate version: 3.2.0.ga
Database: Oracle Database 10.2 XE
JDBC driver: Oracle Thin JDBC Driver 10.1.0.5.0