Fórum

The multi-part identifier "Table_n_.prop" could not be bound

MICHAIL MOUDATSOS, modificado 11 Anos atrás.

The multi-part identifier "Table_n_.prop" could not be bound

Regular Member Postagens: 110 Data de Entrada: 04/10/11 Postagens Recentes
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:
SELECT {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 cp_BaseEntity.name ASC


Turning hibernate.show_sql=true in portal-ext.properties, revealed that this SQL query is actually transformed to the following:
SELECT cp_BaseEntity.baseEntityId as cashPoin1_615_0_, 
		cp_BaseEntity.name as name615_0_, 
		cp_BaseEntity.description as descript3_615_0_, 
		cp_BaseEntity.locationId as locationId615_0_, 
		cp_BaseEntity_1_.balanceRuleId as balanceR2_639_0_, 
		cp_BaseEntity_1_.chargingSchemeId as charging3_639_0_, 
		
		case 
			when cp_BaseEntity_3_.baseEntityId is not null then 3 
			when cp_BaseEntity_4_.baseEntityId is not null then 4 
			when cp_BaseEntity_5_.baseEntityId is not null then 5 
			when cp_BaseEntity_1_.baseEntityId is not null then 1 
			when cp_BaseEntity_2_.baseEntityId is not null then 2 
			when cp_BaseEntity.baseEntityId is not null then 0 
		end as clazz_0_ 
		FROM cp_BaseEntity 
		INNER JOIN cp_BaseEntity_MyGroup 
		ON (cp_BaseEntity_MyGroup.baseEntityId = cp_BaseEntity.baseEntityId) 
		WHERE (cp_BaseEntity_MyGroup.groupId = ?) 
		ORDER BY cp_BaseEntity.name ASC
When MyGroupUtil.getBaseEntities() is executed the following error is thrown at tomcat console:
11:10:11,319 ERROR [http-apr-8080-exec-10][JDBCExceptionReporter:76] The multi-part identifier "cp_BaseEntity_1_.balanceRuleId" could not be bound.
11:10:11,321 ERROR [http-apr-8080-exec-10][JDBCExceptionReporter:76] The multi-part identifier "cp_BaseEntity_1_.chargingSchemeId" could not be bound.
11:10:11,322 ERROR [http-apr-8080-exec-10][JDBCExceptionReporter:76] The multi-part identifier "cp_BaseEntity_3_.baseEntityId" could not be bound.
11:10:11,323 ERROR [http-apr-8080-exec-10][JDBCExceptionReporter:76] The multi-part identifier "cp_BaseEntity_4_.baseEntityId" could not be bound.
11:10:11,326 ERROR [http-apr-8080-exec-10][JDBCExceptionReporter:76] The multi-part identifier "cp_BaseEntity_5_.baseEntityId" could not be bound.
11:10:11,328 ERROR [http-apr-8080-exec-10][JDBCExceptionReporter:76] The multi-part identifier "cp_BaseEntity_1_.baseEntityId" could not be bound.
11: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
SELECT {cp_BaseEntity.*} FROM
portion of the SQL code to
SELECT * FROM
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