I read that manual, Hibernate in Action and two others.
I trace this problem at Hibernate source code and found that, it does not recognize, that all part of primary key are included.
There is a TODO that I guess mean: we have to fix this problem.
See code below:
Code:
org.hibernate.hql.ast.tree.IntoClause
private void visitPropertySpecNodes(AST propertyNode, List types) {
if ( propertyNode == null ) {
return;
}
// TODO : we really need to be able to deal with component paths here also;
// this is difficult because the hql-sql grammar expects all those node types
// to be FromReferenceNodes. One potential fix here would be to convert the
// IntoClause to just use a FromClause/FromElement combo (as a child of the
// InsertStatement) and move all this logic into the InsertStatement. That's
// probably the easiest approach (read: least amount of changes to the grammar
// and code), but just doesn't feel right as then an insert would contain
// 2 from-clauses
String name = propertyNode.getText();
if ( isSuperclassProperty( name ) ) {
throw new QueryException( "INSERT statements cannot refer to superclass/joined properties [" + name + "]" );
}
[b]HERE IT TRIES TO RECOGNIZE PRIMARY KEY, BUT DOES NOT, BECAUSE I HAVE COMPOSITE-ID[/b]
if ( name.equals( persister.getIdentifierPropertyName() ) ) {
explicitIdInsertion = true;
}
if ( persister.isVersioned() ) {
if ( name.equals( persister.getPropertyNames()[ persister.getVersionProperty() ] ) ) {
explicitVersionInsertion = true;
}
}
String[] columnNames = persister.toColumns( name );
renderColumns( columnNames );
types.add( persister.toType( name ) );
// visit width-first, then depth
visitPropertySpecNodes( propertyNode.getNextSibling(), types );
visitPropertySpecNodes( propertyNode.getFirstChild(), types );
}
[/b][/code]