Combination View Flat View Tree View
Threads [ Previous | Next ]
The multi-part identifier "Table_n_.prop" could not be bound
March 11, 2013 9:04 AM


Rank: Regular Member

Posts: 110

Join Date: October 4, 2011

Recent Posts

Hello all,

I hope someone can help me with the following or give me some directions:

I have defined a many-to-many mapping between two custom entities, lets say BaseEntity (corresponded to table cp_BaseEntity with primary key/property baseEntityId) and MyGroup corresponded to table cp_MyGroup with primary key/property groupId. As a consequence, a method MyGroupUtil.getBaseEntities() has been generated by service builder.

The "catch" here is that I have extended my Service-builder generated entity BaseEntity (the BaseEntityImpl, to be more precise), to form a let's say DerivedEntity, as I have described here. I have used joined subclass strategy and the DerivedEntity has two mappings to other generated entities, therefore the joined table has two more columns, let's say balanceRuleId and chargingSchemeId

In the generated MyGroupPersistenceImpl the implementation of getBaseEntities() defines a SQL (native-?-) query that goes like this:
1SELECT {cp_BaseEntity.*} FROM cp_BaseEntity INNER JOIN cp_BaseEntity_MyGroup ON (cp_BaseEntity_MyGroup.baseEntityId = cp_BaseEntity.baseEntityId) WHERE (cp_BaseEntity_MyGroup.groupId = ?) ORDER BY ASC

Turning hibernate.show_sql=true in, revealed that this SQL query is actually transformed to the following:
 1SELECT cp_BaseEntity.baseEntityId as cashPoin1_615_0_,
 2 as name615_0_,
 3        cp_BaseEntity.description as descript3_615_0_,
 4        cp_BaseEntity.locationId as locationId615_0_,
 5        cp_BaseEntity_1_.balanceRuleId as balanceR2_639_0_,
 6        cp_BaseEntity_1_.chargingSchemeId as charging3_639_0_,
 8        case
 9            when cp_BaseEntity_3_.baseEntityId is not null then 3
10            when cp_BaseEntity_4_.baseEntityId is not null then 4
11            when cp_BaseEntity_5_.baseEntityId is not null then 5
12            when cp_BaseEntity_1_.baseEntityId is not null then 1
13            when cp_BaseEntity_2_.baseEntityId is not null then 2
14            when cp_BaseEntity.baseEntityId is not null then 0
15        end as clazz_0_
16        FROM cp_BaseEntity
17        INNER JOIN cp_BaseEntity_MyGroup
18        ON (cp_BaseEntity_MyGroup.baseEntityId = cp_BaseEntity.baseEntityId)
19        WHERE (cp_BaseEntity_MyGroup.groupId = ?)
20        ORDER BY ASC
When MyGroupUtil.getBaseEntities() is executed the following error is thrown at tomcat console:
111:10:11,319 ERROR [http-apr-8080-exec-10][JDBCExceptionReporter:76] The multi-part identifier "cp_BaseEntity_1_.balanceRuleId" could not be bound.
211:10:11,321 ERROR [http-apr-8080-exec-10][JDBCExceptionReporter:76] The multi-part identifier "cp_BaseEntity_1_.chargingSchemeId" could not be bound.
311:10:11,322 ERROR [http-apr-8080-exec-10][JDBCExceptionReporter:76] The multi-part identifier "cp_BaseEntity_3_.baseEntityId" could not be bound.
411:10:11,323 ERROR [http-apr-8080-exec-10][JDBCExceptionReporter:76] The multi-part identifier "cp_BaseEntity_4_.baseEntityId" could not be bound.
511:10:11,326 ERROR [http-apr-8080-exec-10][JDBCExceptionReporter:76] The multi-part identifier "cp_BaseEntity_5_.baseEntityId" could not be bound.
611:10:11,328 ERROR [http-apr-8080-exec-10][JDBCExceptionReporter:76] The multi-part identifier "cp_BaseEntity_1_.baseEntityId" could not be bound.
711:10:11,329 ERROR [http-apr-8080-exec-10][JDBCExceptionReporter:76] The multi-part identifier "cp_BaseEntity_2_.baseEntityId" could not be bound.
Any ideas on this?
If I manually alter the
1SELECT {cp_BaseEntity.*} FROM
portion of the SQL code to
in the generated MyGroupPersistenceImpl, it works fine. Before I resort to solutions such as defining my own persistence implementation through the persistence-class property of the service.xml entity definition, I would like to ask if anyone has a hunch how can I resolve this differently
If I go the persistence-class-property way, will it be OK to extend the generated class and override the corresponding method? Or are there other things to be taken into account?

Thank you in advance

EDIT: Note that the actual problem comes from these, peculiar, cp_BaseEntity_n_ references.
EDIT: It has to do with hibernate inheritance, no doubt since there are indeed 5 classes which subclass directly or indirectly the BaseEntity

Participate in the State of Liferay Community 2017. Help the community and even win some prizes!