Greetings,
I experienced some problems using
where clause.
I have two tables,
service and
properties.
In
service, there is a reference to the same table for parent service.
In
properties there is a foreign key referencing
service table.
Now I have service 1, without any parent, and service 3, whose parent is service 1.
If I try to fetch service 3 without fetching service 1 first, then I get the
JOIN/ON clause refers to "properties", which is not part of JOIN error.
So, what am I missing? Can somebody help me to figure it out, please?
The cause I provided below is minimal. Removing of parent service, properties, or
where clause result in program running OK.
Hibernate version:
hibernate-3.1.2, hibernate-annotations-3.1beta8
Mapping documents:
Code:
package cz.test;
import java.util.Set;
import javax.persistence.*;
import org.hibernate.annotations.Where;
@Entity
@Table(name="service", schema="public")
public class ServiceT implements java.io.Serializable {
@Id
@Column(name = "service_id")
public Integer id;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "parent_service_id")
public ServiceT parentService;
@OneToMany(targetEntity = PropertyT.class, fetch = FetchType.EAGER)
@JoinColumn(name = "foreign_id")
@Where(clause = "properties.id_type = 'service'")
public Set<PropertyT> properties;
public ServiceT() {
}
public ServiceT(Integer serviceId) {
this.id = serviceId;
}
public int hashCode() {
return id;
}
public boolean equals(Object other) {
if (other instanceof ServiceT
&& ((ServiceT) other).id
.equals(id))
return true;
return false;
}
}
-----------------------------------------------------------
package cz.test;
import java.io.Serializable;
import javax.persistence.*;
@Entity
@Table(name="properties")
public class PropertyT implements Serializable{
@Id
@Column(name="prop_id")
public Integer propId;
@Column(name="foreign_id")
public Integer foreignId;
@Column(name="id_type")
public String idType;
public PropertyT() {}
public PropertyT(Integer propId) {this.propId=propId;}
public int hashCode() {
return propId;
}
public boolean equals(Object other) {
if (other instanceof PropertyT && ((PropertyT) other).propId.equals(propId)) return true;
return false;
}
}
Code between sessionFactory.openSession() and session.close():Code:
// sess.createQuery("from ServiceT where id=1").list(); works fine if uncommented
sess.createQuery("from ServiceT where id=3").list();
Full stack trace of any exception that occurs:see the debug level log
Name and version of the database you are using:PostgreSQL 7.4.7
Sql statementsCode:
Hibernate: select servicet0_.service_id as service1_0_, servicet0_.parent_service_id as parent2_0_ from public.service servicet0_ where servicet0_.service_id=3
Hibernate: select servicet0_.service_id as service1_0_2_, servicet0_.parent_service_id as parent2_0_2_, servicet1_.service_id as service1_0_0_, servicet1_.parent_service_id as parent2_0_0_, properties2_.foreign_id as foreign2_4_, properties2_.prop_id as prop1_4_, properties2_.prop_id as prop1_1_1_, properties2_.foreign_id as foreign2_1_1_, properties2_.id_type as id3_1_1_ from public.service servicet0_ left outer join public.service servicet1_ on servicet0_.parent_service_id=servicet1_.service_id left outer join properties properties2_ on servicet1_.service_id=properties2_.foreign_id and properties.id_type = 'service' where servicet0_.service_id=?
Debug level Hibernate log excerpt:Code:
08.02.06 14:36:42,242 INFO org.hibernate.cfg.Environment Hibernate 3.1.2
08.02.06 14:36:42,258 INFO org.hibernate.cfg.Environment hibernate.properties not found
08.02.06 14:36:42,258 INFO org.hibernate.cfg.Environment using CGLIB reflection optimizer
08.02.06 14:36:42,258 INFO org.hibernate.cfg.Environment using JDK 1.4 java.sql.Timestamp handling
08.02.06 14:36:42,445 DEBUG org.hibernate.cfg.Configuration Preparing to build session factory with filters : {}
08.02.06 14:36:42,445 DEBUG org.hibernate.cfg.AnnotationConfiguration Execute first pass mapping processing
08.02.06 14:36:42,492 DEBUG org.hibernate.cfg.AnnotationConfiguration Process hbm files
08.02.06 14:36:42,492 DEBUG org.hibernate.cfg.AnnotationConfiguration Process annotated classes
08.02.06 14:36:42,648 INFO org.hibernate.cfg.AnnotationBinder Binding entity from annotated class: cz.test.ServiceT
08.02.06 14:36:42,695 DEBUG org.hibernate.cfg.Ejb3Column Binding column TYPE unique false
08.02.06 14:36:42,711 DEBUG org.hibernate.cfg.annotations.EntityBinder Import with entity name=ServiceT
08.02.06 14:36:42,726 INFO org.hibernate.cfg.annotations.EntityBinder Bind entity cz.test.ServiceT on table service
08.02.06 14:36:42,742 DEBUG org.hibernate.cfg.AnnotationBinder Processing cz.test.ServiceT per property annotation
08.02.06 14:36:42,742 DEBUG org.hibernate.cfg.AnnotationBinder Processing cz.test.ServiceT per field annotation
08.02.06 14:36:42,804 DEBUG org.hibernate.cfg.AnnotationBinder Processing annotations of cz.test.ServiceT.id
08.02.06 14:36:42,820 DEBUG org.hibernate.cfg.Ejb3Column Binding column service_id unique false
08.02.06 14:36:42,820 DEBUG org.hibernate.cfg.AnnotationBinder id is an id
08.02.06 14:36:42,820 DEBUG org.hibernate.cfg.annotations.SimpleValueBinder building SimpleValue for id
08.02.06 14:36:42,836 DEBUG org.hibernate.cfg.annotations.PropertyBinder Building property id
08.02.06 14:36:42,836 DEBUG org.hibernate.cfg.annotations.PropertyBinder Cascading id with null
08.02.06 14:36:42,836 DEBUG org.hibernate.cfg.AnnotationBinder Bind @Id on id
08.02.06 14:36:42,836 DEBUG org.hibernate.cfg.AnnotationBinder Processing annotations of cz.test.ServiceT.parentService
08.02.06 14:36:42,836 DEBUG org.hibernate.cfg.Ejb3Column Binding column parent_service_id unique false
08.02.06 14:36:42,851 DEBUG org.hibernate.cfg.Ejb3Column Binding column parentService unique false
08.02.06 14:36:42,867 DEBUG org.hibernate.cfg.annotations.PropertyBinder Building property parentService
08.02.06 14:36:42,867 DEBUG org.hibernate.cfg.annotations.PropertyBinder Cascading parentService with none
08.02.06 14:36:42,867 DEBUG org.hibernate.cfg.AnnotationBinder Processing annotations of cz.test.ServiceT.properties
08.02.06 14:36:42,867 DEBUG org.hibernate.cfg.Ejb3Column Binding column foreign_id unique false
08.02.06 14:36:42,867 DEBUG org.hibernate.cfg.Ejb3Column Binding column properties unique false
08.02.06 14:36:42,867 DEBUG org.hibernate.cfg.Ejb3Column Binding column null unique false
08.02.06 14:36:42,883 DEBUG org.hibernate.cfg.Ejb3Column Binding column null unique false
08.02.06 14:36:42,898 DEBUG org.hibernate.cfg.Ejb3Column Binding column null unique false
08.02.06 14:36:42,898 DEBUG org.hibernate.cfg.annotations.CollectionBinder Collection role: cz.test.ServiceT.properties
08.02.06 14:36:42,898 DEBUG org.hibernate.cfg.annotations.PropertyBinder Building property properties
08.02.06 14:36:42,898 DEBUG org.hibernate.cfg.annotations.PropertyBinder Cascading properties with none
08.02.06 14:36:42,914 DEBUG org.hibernate.validator.ClassValidator ResourceBundle ValidatorMessages not found. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages
08.02.06 14:36:42,929 INFO org.hibernate.cfg.AnnotationBinder Binding entity from annotated class: cz.test.PropertyT
08.02.06 14:36:42,929 DEBUG org.hibernate.cfg.Ejb3Column Binding column TYPE unique false
08.02.06 14:36:42,929 DEBUG org.hibernate.cfg.annotations.EntityBinder Import with entity name=PropertyT
08.02.06 14:36:42,929 INFO org.hibernate.cfg.annotations.EntityBinder Bind entity cz.test.PropertyT on table properties
08.02.06 14:36:42,929 DEBUG org.hibernate.cfg.AnnotationBinder Processing cz.test.PropertyT per property annotation
08.02.06 14:36:42,929 DEBUG org.hibernate.cfg.AnnotationBinder Processing cz.test.PropertyT per field annotation
08.02.06 14:36:42,929 DEBUG org.hibernate.cfg.AnnotationBinder Processing annotations of cz.test.PropertyT.propId
08.02.06 14:36:42,929 DEBUG org.hibernate.cfg.Ejb3Column Binding column prop_id unique false
08.02.06 14:36:42,929 DEBUG org.hibernate.cfg.AnnotationBinder propId is an id
08.02.06 14:36:42,929 DEBUG org.hibernate.cfg.annotations.SimpleValueBinder building SimpleValue for propId
08.02.06 14:36:42,929 DEBUG org.hibernate.cfg.annotations.PropertyBinder Building property propId
08.02.06 14:36:42,929 DEBUG org.hibernate.cfg.annotations.PropertyBinder Cascading propId with null
08.02.06 14:36:42,929 DEBUG org.hibernate.cfg.AnnotationBinder Bind @Id on propId
08.02.06 14:36:42,929 DEBUG org.hibernate.cfg.AnnotationBinder Processing annotations of cz.test.PropertyT.foreignId
08.02.06 14:36:42,945 DEBUG org.hibernate.cfg.Ejb3Column Binding column foreign_id unique false
08.02.06 14:36:42,945 DEBUG org.hibernate.cfg.annotations.PropertyBinder binding property foreignId with lazy=false
08.02.06 14:36:42,945 DEBUG org.hibernate.cfg.annotations.SimpleValueBinder building SimpleValue for foreignId
08.02.06 14:36:42,945 DEBUG org.hibernate.cfg.annotations.PropertyBinder Building property foreignId
08.02.06 14:36:42,945 DEBUG org.hibernate.cfg.annotations.PropertyBinder Cascading foreignId with null
08.02.06 14:36:42,945 DEBUG org.hibernate.cfg.AnnotationBinder Processing annotations of cz.test.PropertyT.idType
08.02.06 14:36:42,945 DEBUG org.hibernate.cfg.Ejb3Column Binding column id_type unique false
08.02.06 14:36:42,945 DEBUG org.hibernate.cfg.annotations.PropertyBinder binding property idType with lazy=false
08.02.06 14:36:42,945 DEBUG org.hibernate.cfg.annotations.SimpleValueBinder building SimpleValue for idType
08.02.06 14:36:42,945 DEBUG org.hibernate.cfg.annotations.PropertyBinder Building property idType
08.02.06 14:36:42,945 DEBUG org.hibernate.cfg.annotations.PropertyBinder Cascading idType with null
08.02.06 14:36:42,945 DEBUG org.hibernate.validator.ClassValidator ResourceBundle ValidatorMessages not found. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages
08.02.06 14:36:42,945 DEBUG org.hibernate.cfg.AnnotationConfiguration processing manytoone fk mappings
08.02.06 14:36:43,101 DEBUG org.hibernate.cfg.Configuration processing extends queue
08.02.06 14:36:43,101 DEBUG org.hibernate.cfg.Configuration processing collection mappings
08.02.06 14:36:43,101 DEBUG org.hibernate.cfg.CollectionSecondPass Second pass for collection: cz.test.ServiceT.properties
08.02.06 14:36:43,101 DEBUG org.hibernate.cfg.annotations.CollectionBinder Binding a OneToMany: cz.test.ServiceT.properties through a foreign key
08.02.06 14:36:43,132 INFO org.hibernate.cfg.annotations.CollectionBinder Mapping collection: cz.test.ServiceT.properties -> properties
08.02.06 14:36:43,132 DEBUG org.hibernate.cfg.CollectionSecondPass Mapped collection key: foreign_id, one-to-many: cz.test.PropertyT
08.02.06 14:36:43,132 DEBUG org.hibernate.cfg.Configuration processing native query and ResultSetMapping mappings
08.02.06 14:36:43,132 DEBUG org.hibernate.cfg.Configuration processing association property references
08.02.06 14:36:43,132 DEBUG org.hibernate.cfg.Configuration processing foreign key constraints
08.02.06 14:36:43,211 DEBUG org.hibernate.cfg.Configuration resolving reference to class: cz.test.ServiceT
08.02.06 14:36:43,211 DEBUG org.hibernate.cfg.Configuration resolving reference to class: cz.test.ServiceT
08.02.06 14:36:43,226 INFO org.hibernate.connection.DriverManagerConnectionProvider Using Hibernate built-in connection pool (not for production use!)
08.02.06 14:36:43,226 INFO org.hibernate.connection.DriverManagerConnectionProvider Hibernate connection pool size: 5
08.02.06 14:36:43,226 INFO org.hibernate.connection.DriverManagerConnectionProvider autocommit mode: false
08.02.06 14:36:43,242 INFO org.hibernate.connection.DriverManagerConnectionProvider using driver: org.postgresql.Driver at URL: jdbc:postgresql://url
08.02.06 14:36:43,242 INFO org.hibernate.connection.DriverManagerConnectionProvider connection properties: {user=****, password=****}
08.02.06 14:36:43,242 DEBUG org.hibernate.connection.DriverManagerConnectionProvider total checked-out connections: 0
08.02.06 14:36:43,242 DEBUG org.hibernate.connection.DriverManagerConnectionProvider opening new JDBC connection
08.02.06 14:36:43,476 DEBUG org.hibernate.connection.DriverManagerConnectionProvider created connection to: jdbc:postgresql://url, Isolation Level: 2
08.02.06 14:36:43,507 INFO org.hibernate.cfg.SettingsFactory RDBMS: PostgreSQL, version: 7.4.7
08.02.06 14:36:43,523 INFO org.hibernate.cfg.SettingsFactory JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.1devel JDBC3 with SSL (build 400)
08.02.06 14:36:43,523 DEBUG org.hibernate.connection.DriverManagerConnectionProvider returning connection to pool, pool size: 1
08.02.06 14:36:43,570 INFO org.hibernate.dialect.Dialect Using dialect: org.hibernate.dialect.PostgreSQLDialect
08.02.06 14:36:43,586 INFO org.hibernate.transaction.TransactionFactoryFactory Using default transaction strategy (direct JDBC transactions)
08.02.06 14:36:43,601 INFO org.hibernate.transaction.TransactionManagerLookupFactory No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
08.02.06 14:36:43,601 INFO org.hibernate.cfg.SettingsFactory Automatic flush during beforeCompletion(): disabled
08.02.06 14:36:43,601 INFO org.hibernate.cfg.SettingsFactory Automatic session close at end of transaction: disabled
08.02.06 14:36:43,601 INFO org.hibernate.cfg.SettingsFactory JDBC batch size: 15
08.02.06 14:36:43,601 INFO org.hibernate.cfg.SettingsFactory JDBC batch updates for versioned data: disabled
08.02.06 14:36:43,601 INFO org.hibernate.cfg.SettingsFactory Scrollable result sets: enabled
08.02.06 14:36:43,601 DEBUG org.hibernate.cfg.SettingsFactory Wrap result sets: disabled
08.02.06 14:36:43,601 INFO org.hibernate.cfg.SettingsFactory JDBC3 getGeneratedKeys(): disabled
08.02.06 14:36:43,601 INFO org.hibernate.cfg.SettingsFactory Connection release mode: auto
08.02.06 14:36:43,601 INFO org.hibernate.cfg.SettingsFactory Default batch fetch size: 1
08.02.06 14:36:43,601 INFO org.hibernate.cfg.SettingsFactory Generate SQL with comments: disabled
08.02.06 14:36:43,601 INFO org.hibernate.cfg.SettingsFactory Order SQL updates by primary key: disabled
08.02.06 14:36:43,601 INFO org.hibernate.cfg.SettingsFactory Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
08.02.06 14:36:43,617 INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory Using ASTQueryTranslatorFactory
08.02.06 14:36:43,617 INFO org.hibernate.cfg.SettingsFactory Query language substitutions: {}
08.02.06 14:36:43,617 INFO org.hibernate.cfg.SettingsFactory Second-level cache: enabled
08.02.06 14:36:43,617 INFO org.hibernate.cfg.SettingsFactory Query cache: disabled
08.02.06 14:36:43,617 INFO org.hibernate.cfg.SettingsFactory Cache provider: org.hibernate.cache.EhCacheProvider
08.02.06 14:36:43,648 INFO org.hibernate.cfg.SettingsFactory Optimize cache for minimal puts: disabled
08.02.06 14:36:43,648 INFO org.hibernate.cfg.SettingsFactory Structured second-level cache entries: disabled
08.02.06 14:36:43,664 DEBUG org.hibernate.exception.SQLExceptionConverterFactory Using dialect defined converter
08.02.06 14:36:43,664 INFO org.hibernate.cfg.SettingsFactory Echoing all SQL to stdout
08.02.06 14:36:43,679 INFO org.hibernate.cfg.SettingsFactory Statistics: disabled
08.02.06 14:36:43,679 INFO org.hibernate.cfg.SettingsFactory Deleted entity synthetic identifier rollback: disabled
08.02.06 14:36:43,679 INFO org.hibernate.cfg.SettingsFactory Default entity-mode: pojo
08.02.06 14:36:43,742 INFO org.hibernate.impl.SessionFactoryImpl building session factory
08.02.06 14:36:43,742 DEBUG org.hibernate.impl.SessionFactoryImpl Session factory constructed with filter configurations : {}
08.02.06 14:36:43,742 DEBUG org.hibernate.impl.SessionFactoryImpl instantiating session factory with properties: {hibernate.connection.username=****, hibernate.connection.password=****, hibernate.connection.pool_size=5, hibernate.connection.url=jdbc:postgresql://url, hibernate.show_sql=true, hibernate.connection.driver_class=org.postgresql.Driver}
08.02.06 14:36:43,804 WARN net.sf.ehcache.config.Configurator No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: file:/E:/projekty/central%20novy/bin/ehcache-failsafe.xml
08.02.06 14:36:44,320 DEBUG org.hibernate.persister.entity.AbstractEntityPersister Static SQL for entity: cz.test.PropertyT
08.02.06 14:36:44,320 DEBUG org.hibernate.persister.entity.AbstractEntityPersister Version select: select prop_id from properties where prop_id =?
08.02.06 14:36:44,320 DEBUG org.hibernate.persister.entity.AbstractEntityPersister Snapshot select: select propertyt_.prop_id, propertyt_.foreign_id as foreign2_1_, propertyt_.id_type as id3_1_ from properties propertyt_ where propertyt_.prop_id=?
08.02.06 14:36:44,320 DEBUG org.hibernate.persister.entity.AbstractEntityPersister Insert 0: insert into properties (foreign_id, id_type, prop_id) values (?, ?, ?)
08.02.06 14:36:44,320 DEBUG org.hibernate.persister.entity.AbstractEntityPersister Update 0: update properties set foreign_id=?, id_type=? where prop_id=?
08.02.06 14:36:44,320 DEBUG org.hibernate.persister.entity.AbstractEntityPersister Delete 0: delete from properties where prop_id=?
08.02.06 14:36:44,336 DEBUG org.hibernate.persister.entity.AbstractEntityPersister Static SQL for entity: cz.test.ServiceT
08.02.06 14:36:44,336 DEBUG org.hibernate.persister.entity.AbstractEntityPersister Version select: select service_id from public.service where service_id =?
08.02.06 14:36:44,336 DEBUG org.hibernate.persister.entity.AbstractEntityPersister Snapshot select: select servicet_.service_id, servicet_.parent_service_id as parent2_0_ from public.service servicet_ where servicet_.service_id=?
08.02.06 14:36:44,336 DEBUG org.hibernate.persister.entity.AbstractEntityPersister Insert 0: insert into public.service (parent_service_id, service_id) values (?, ?)
08.02.06 14:36:44,336 DEBUG org.hibernate.persister.entity.AbstractEntityPersister Update 0: update public.service set parent_service_id=? where service_id=?
08.02.06 14:36:44,336 DEBUG org.hibernate.persister.entity.AbstractEntityPersister Delete 0: delete from public.service where service_id=?
08.02.06 14:36:44,351 DEBUG org.hibernate.persister.collection.AbstractCollectionPersister Static SQL for collection: cz.test.ServiceT.properties
08.02.06 14:36:44,351 DEBUG org.hibernate.persister.collection.AbstractCollectionPersister Row insert: update properties set foreign_id=? where prop_id=?
08.02.06 14:36:44,351 DEBUG org.hibernate.persister.collection.AbstractCollectionPersister Row delete: update properties set foreign_id=null where foreign_id=? and prop_id=?
08.02.06 14:36:44,351 DEBUG org.hibernate.persister.collection.AbstractCollectionPersister One-shot delete: update properties set foreign_id=null where foreign_id=? and properties.id_type = 'service'
08.02.06 14:36:44,398 DEBUG org.hibernate.loader.entity.EntityLoader Static select for entity cz.test.PropertyT: select propertyt0_.prop_id as prop1_1_0_, propertyt0_.foreign_id as foreign2_1_0_, propertyt0_.id_type as id3_1_0_ from properties propertyt0_ where propertyt0_.prop_id=?
08.02.06 14:36:44,398 DEBUG org.hibernate.loader.entity.EntityLoader Static select for entity cz.test.PropertyT: select propertyt0_.prop_id as prop1_1_0_, propertyt0_.foreign_id as foreign2_1_0_, propertyt0_.id_type as id3_1_0_ from properties propertyt0_ where propertyt0_.prop_id=?
08.02.06 14:36:44,398 DEBUG org.hibernate.loader.entity.EntityLoader Static select for entity cz.test.PropertyT: select propertyt0_.prop_id as prop1_1_0_, propertyt0_.foreign_id as foreign2_1_0_, propertyt0_.id_type as id3_1_0_ from properties propertyt0_ where propertyt0_.prop_id=? for update
08.02.06 14:36:44,398 DEBUG org.hibernate.loader.entity.EntityLoader Static select for entity cz.test.PropertyT: select propertyt0_.prop_id as prop1_1_0_, propertyt0_.foreign_id as foreign2_1_0_, propertyt0_.id_type as id3_1_0_ from properties propertyt0_ where propertyt0_.prop_id=? for update
08.02.06 14:36:44,414 DEBUG org.hibernate.loader.entity.EntityLoader Static select for action ACTION_MERGE on entity cz.test.PropertyT: select propertyt0_.prop_id as prop1_1_0_, propertyt0_.foreign_id as foreign2_1_0_, propertyt0_.id_type as id3_1_0_ from properties propertyt0_ where propertyt0_.prop_id=?
08.02.06 14:36:44,429 DEBUG org.hibernate.loader.entity.EntityLoader Static select for action ACTION_REFRESH on entity cz.test.PropertyT: select propertyt0_.prop_id as prop1_1_0_, propertyt0_.foreign_id as foreign2_1_0_, propertyt0_.id_type as id3_1_0_ from properties propertyt0_ where propertyt0_.prop_id=?
08.02.06 14:36:44,429 DEBUG org.hibernate.loader.entity.EntityLoader Static select for entity cz.test.ServiceT: select servicet0_.service_id as service1_0_2_, servicet0_.parent_service_id as parent2_0_2_, servicet1_.service_id as service1_0_0_, servicet1_.parent_service_id as parent2_0_0_, properties2_.foreign_id as foreign2_4_, properties2_.prop_id as prop1_4_, properties2_.prop_id as prop1_1_1_, properties2_.foreign_id as foreign2_1_1_, properties2_.id_type as id3_1_1_ from public.service servicet0_ left outer join public.service servicet1_ on servicet0_.parent_service_id=servicet1_.service_id left outer join properties properties2_ on servicet1_.service_id=properties2_.foreign_id and properties.id_type = 'service' where servicet0_.service_id=?
08.02.06 14:36:44,429 DEBUG org.hibernate.loader.entity.EntityLoader Static select for entity cz.test.ServiceT: select servicet0_.service_id as service1_0_2_, servicet0_.parent_service_id as parent2_0_2_, servicet1_.service_id as service1_0_0_, servicet1_.parent_service_id as parent2_0_0_, properties2_.foreign_id as foreign2_4_, properties2_.prop_id as prop1_4_, properties2_.prop_id as prop1_1_1_, properties2_.foreign_id as foreign2_1_1_, properties2_.id_type as id3_1_1_ from public.service servicet0_ left outer join public.service servicet1_ on servicet0_.parent_service_id=servicet1_.service_id left outer join properties properties2_ on servicet1_.service_id=properties2_.foreign_id and properties.id_type = 'service' where servicet0_.service_id=?
08.02.06 14:36:44,429 DEBUG org.hibernate.loader.entity.EntityLoader Static select for entity cz.test.ServiceT: select servicet0_.service_id as service1_0_0_, servicet0_.parent_service_id as parent2_0_0_ from public.service servicet0_ where servicet0_.service_id=? for update
08.02.06 14:36:44,429 DEBUG org.hibernate.loader.entity.EntityLoader Static select for entity cz.test.ServiceT: select servicet0_.service_id as service1_0_0_, servicet0_.parent_service_id as parent2_0_0_ from public.service servicet0_ where servicet0_.service_id=? for update
08.02.06 14:36:44,429 DEBUG org.hibernate.loader.entity.EntityLoader Static select for action ACTION_MERGE on entity cz.test.ServiceT: select servicet0_.service_id as service1_0_0_, servicet0_.parent_service_id as parent2_0_0_ from public.service servicet0_ where servicet0_.service_id=?
08.02.06 14:36:44,429 DEBUG org.hibernate.loader.entity.EntityLoader Static select for action ACTION_REFRESH on entity cz.test.ServiceT: select servicet0_.service_id as service1_0_0_, servicet0_.parent_service_id as parent2_0_0_ from public.service servicet0_ where servicet0_.service_id=?
08.02.06 14:36:44,445 DEBUG org.hibernate.loader.collection.OneToManyLoader Static select for one-to-many cz.test.ServiceT.properties: select properties0_.foreign_id as foreign2_1_, properties0_.prop_id as prop1_1_, properties0_.prop_id as prop1_1_0_, properties0_.foreign_id as foreign2_1_0_, properties0_.id_type as id3_1_0_ from properties properties0_ where properties.id_type = 'service' and properties0_.foreign_id=?
08.02.06 14:36:44,445 DEBUG org.hibernate.impl.SessionFactoryObjectFactory initializing class SessionFactoryObjectFactory
08.02.06 14:36:44,476 DEBUG org.hibernate.impl.SessionFactoryObjectFactory registered: d1dfe8320949e0d0010949e0d39d0000 (unnamed)
08.02.06 14:36:44,476 INFO org.hibernate.impl.SessionFactoryObjectFactory Not binding factory to JNDI, no JNDI name configured
08.02.06 14:36:44,476 DEBUG org.hibernate.impl.SessionFactoryImpl instantiated session factory
08.02.06 14:36:44,476 DEBUG org.hibernate.impl.SessionFactoryImpl Checking 0 named HQL queries
08.02.06 14:36:44,476 DEBUG org.hibernate.impl.SessionFactoryImpl Checking 0 named SQL queries
08.02.06 14:36:44,570 DEBUG org.hibernate.impl.SessionImpl opened session at timestamp: 4667006175133696
08.02.06 14:36:44,586 DEBUG org.hibernate.transaction.JDBCTransaction begin
08.02.06 14:36:44,586 DEBUG org.hibernate.jdbc.ConnectionManager opening JDBC connection
08.02.06 14:36:44,586 DEBUG org.hibernate.connection.DriverManagerConnectionProvider total checked-out connections: 0
08.02.06 14:36:44,586 DEBUG org.hibernate.connection.DriverManagerConnectionProvider using pooled JDBC connection, pool size: 0
08.02.06 14:36:44,586 DEBUG org.hibernate.transaction.JDBCTransaction current autocommit status: false
08.02.06 14:36:44,586 DEBUG org.hibernate.jdbc.JDBCContext after transaction begin
08.02.06 14:36:44,586 DEBUG org.hibernate.engine.query.QueryPlanCache unable to locate HQL query plan in cache; generating (from ServiceT where id=3)
08.02.06 14:36:44,695 DEBUG org.hibernate.hql.ast.QueryTranslatorImpl parse() - HQL: from cz.test.ServiceT where id=3
08.02.06 14:36:44,726 DEBUG org.hibernate.hql.ast.AST --- HQL AST ---
\-[QUERY] 'query'
+-[SELECT_FROM] 'SELECT_FROM'
| \-[FROM] 'from'
| \-[RANGE] 'RANGE'
| \-[DOT] '.'
| +-[DOT] '.'
| | +-[IDENT] 'cz'
| | \-[IDENT] 'test'
| \-[IDENT] 'ServiceT'
\-[WHERE] 'where'
\-[EQ] '='
+-[IDENT] 'id'
\-[NUM_INT] '3'
08.02.06 14:36:44,726 DEBUG org.hibernate.hql.ast.ErrorCounter throwQueryException() : no errors
08.02.06 14:36:44,804 DEBUG org.hibernate.hql.antlr.HqlSqlBaseWalker select << begin [level=1, statement=select]
08.02.06 14:36:44,836 DEBUG org.hibernate.hql.ast.tree.FromElement FromClause{level=1} : cz.test.ServiceT (no alias) -> servicet0_
08.02.06 14:36:44,836 DEBUG org.hibernate.hql.ast.HqlSqlWalker attempting to resolve property [id] as a non-qualified ref
08.02.06 14:36:44,836 DEBUG org.hibernate.hql.ast.tree.FromReferenceNode Resolved : {synthetic-alias} -> {synthetic-alias}
08.02.06 14:36:44,836 DEBUG org.hibernate.hql.ast.tree.DotNode getDataType() : id -> org.hibernate.type.IntegerType@648016
08.02.06 14:36:44,836 DEBUG org.hibernate.hql.ast.tree.FromReferenceNode Resolved : {synthetic-alias}.id -> servicet0_.service_id
08.02.06 14:36:44,836 DEBUG org.hibernate.hql.antlr.HqlSqlBaseWalker select : finishing up [level=1, statement=select]
08.02.06 14:36:44,836 DEBUG org.hibernate.hql.ast.HqlSqlWalker processQuery() : ( SELECT ( FromClause{level=1} public.service servicet0_ ) ( where ( = ( servicet0_.service_id {synthetic-alias} id ) 3 ) ) )
08.02.06 14:36:44,851 DEBUG org.hibernate.hql.ast.HqlSqlWalker Derived SELECT clause created.
08.02.06 14:36:44,867 DEBUG org.hibernate.hql.ast.util.JoinProcessor Using FROM fragment [public.service servicet0_]
08.02.06 14:36:44,867 DEBUG org.hibernate.hql.antlr.HqlSqlBaseWalker select >> end [level=1, statement=select]
08.02.06 14:36:44,867 DEBUG org.hibernate.hql.ast.AST --- SQL AST ---
\-[SELECT] QueryNode: 'SELECT' querySpaces (public.service)
+-[SELECT_CLAUSE] SelectClause: '{derived select clause}'
| +-[SELECT_EXPR] SelectExpressionImpl: 'servicet0_.service_id as service1_0_' {FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=public.service,tableAlias=servicet0_,origin=null,colums={,className=cz.test.ServiceT}}}
| \-[SQL_TOKEN] SqlFragment: 'servicet0_.parent_service_id as parent2_0_'
+-[FROM] FromClause: 'from' FromClause{level=1, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[], fromElementByTableAlias=[servicet0_], fromElementsByPath=[], collectionJoinFromElementsByPath=[], impliedElements=[]}
| \-[FROM_FRAGMENT] FromElement: 'public.service servicet0_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=public.service,tableAlias=servicet0_,origin=null,colums={,className=cz.test.ServiceT}}
\-[WHERE] SqlNode: 'where'
\-[EQ] BinaryLogicOperatorNode: '='
+-[DOT] DotNode: 'servicet0_.service_id' {propertyName=id,dereferenceType=4,propertyPath=id,path={synthetic-alias}.id,tableAlias=servicet0_,className=cz.test.ServiceT,classAlias=null}
| +-[IDENT] IdentNode: '{synthetic-alias}' {originalText={synthetic-alias}}
| \-[IDENT] IdentNode: 'id' {originalText=id}
\-[NUM_INT] LiteralNode: '3'
08.02.06 14:36:44,867 DEBUG org.hibernate.hql.ast.ErrorCounter throwQueryException() : no errors
08.02.06 14:36:44,898 DEBUG org.hibernate.hql.ast.QueryTranslatorImpl HQL: from cz.test.ServiceT where id=3
08.02.06 14:36:44,898 DEBUG org.hibernate.hql.ast.QueryTranslatorImpl SQL: select servicet0_.service_id as service1_0_, servicet0_.parent_service_id as parent2_0_ from public.service servicet0_ where servicet0_.service_id=3
08.02.06 14:36:44,898 DEBUG org.hibernate.hql.ast.ErrorCounter throwQueryException() : no errors
08.02.06 14:36:44,914 DEBUG org.hibernate.engine.query.HQLQueryPlan HQL param location recognition took 0 mills (from ServiceT where id=3)
08.02.06 14:36:44,914 DEBUG org.hibernate.engine.query.QueryPlanCache located HQL query plan in cache (from ServiceT where id=3)
08.02.06 14:36:44,914 DEBUG org.hibernate.engine.query.HQLQueryPlan find: from ServiceT where id=3
08.02.06 14:36:44,929 DEBUG org.hibernate.engine.QueryParameters named parameters: {}
08.02.06 14:36:44,929 DEBUG org.hibernate.jdbc.AbstractBatcher about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
08.02.06 14:36:44,929 DEBUG org.hibernate.SQL select servicet0_.service_id as service1_0_, servicet0_.parent_service_id as parent2_0_ from public.service servicet0_ where servicet0_.service_id=3
08.02.06 14:36:44,929 DEBUG org.hibernate.jdbc.AbstractBatcher preparing statement
08.02.06 14:36:44,945 DEBUG org.hibernate.jdbc.AbstractBatcher about to open ResultSet (open ResultSets: 0, globally: 0)
08.02.06 14:36:44,945 DEBUG org.hibernate.loader.Loader processing result set
08.02.06 14:36:44,945 DEBUG org.hibernate.loader.Loader result set row: 0
08.02.06 14:36:44,945 DEBUG org.hibernate.type.IntegerType returning '3' as column: service1_0_
08.02.06 14:36:44,945 DEBUG org.hibernate.loader.Loader result row: EntityKey[cz.test.ServiceT#3]
08.02.06 14:36:44,945 DEBUG org.hibernate.loader.Loader Initializing object from ResultSet: [cz.test.ServiceT#3]
08.02.06 14:36:44,976 DEBUG org.hibernate.persister.entity.AbstractEntityPersister Hydrating entity: [cz.test.ServiceT#3]
08.02.06 14:36:44,976 DEBUG org.hibernate.type.IntegerType returning '1' as column: parent2_0_
08.02.06 14:36:44,976 DEBUG org.hibernate.loader.Loader done processing result set (1 rows)
08.02.06 14:36:44,976 DEBUG org.hibernate.jdbc.AbstractBatcher about to close ResultSet (open ResultSets: 1, globally: 1)
08.02.06 14:36:44,976 DEBUG org.hibernate.jdbc.AbstractBatcher about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
08.02.06 14:36:44,976 DEBUG org.hibernate.jdbc.AbstractBatcher closing statement
08.02.06 14:36:44,976 DEBUG org.hibernate.loader.Loader total objects hydrated: 1
08.02.06 14:36:44,976 DEBUG org.hibernate.engine.TwoPhaseLoad resolving associations for [cz.test.ServiceT#3]
08.02.06 14:36:44,992 DEBUG org.hibernate.event.def.DefaultLoadEventListener loading entity: [cz.test.ServiceT#1]
08.02.06 14:36:44,992 DEBUG org.hibernate.event.def.DefaultLoadEventListener attempting to resolve: [cz.test.ServiceT#1]
08.02.06 14:36:44,992 DEBUG org.hibernate.event.def.DefaultLoadEventListener object not resolved in any cache: [cz.test.ServiceT#1]
08.02.06 14:36:44,992 DEBUG org.hibernate.persister.entity.AbstractEntityPersister Fetching entity: [cz.test.ServiceT#1]
08.02.06 14:36:44,992 DEBUG org.hibernate.loader.Loader loading entity: [cz.test.ServiceT#1]
08.02.06 14:36:44,992 DEBUG org.hibernate.jdbc.AbstractBatcher about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
08.02.06 14:36:44,992 DEBUG org.hibernate.SQL select servicet0_.service_id as service1_0_2_, servicet0_.parent_service_id as parent2_0_2_, servicet1_.service_id as service1_0_0_, servicet1_.parent_service_id as parent2_0_0_, properties2_.foreign_id as foreign2_4_, properties2_.prop_id as prop1_4_, properties2_.prop_id as prop1_1_1_, properties2_.foreign_id as foreign2_1_1_, properties2_.id_type as id3_1_1_ from public.service servicet0_ left outer join public.service servicet1_ on servicet0_.parent_service_id=servicet1_.service_id left outer join properties properties2_ on servicet1_.service_id=properties2_.foreign_id and properties.id_type = 'service' where servicet0_.service_id=?
08.02.06 14:36:44,992 DEBUG org.hibernate.jdbc.AbstractBatcher preparing statement
08.02.06 14:36:44,992 DEBUG org.hibernate.type.IntegerType binding '1' to parameter: 1
08.02.06 14:36:44,992 DEBUG org.hibernate.jdbc.AbstractBatcher about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
08.02.06 14:36:44,992 DEBUG org.hibernate.jdbc.AbstractBatcher closing statement
08.02.06 14:36:45,023 DEBUG org.hibernate.util.JDBCExceptionReporter could not load an entity: [cz.test.ServiceT#1] [select servicet0_.service_id as service1_0_2_, servicet0_.parent_service_id as parent2_0_2_, servicet1_.service_id as service1_0_0_, servicet1_.parent_service_id as parent2_0_0_, properties2_.foreign_id as foreign2_4_, properties2_.prop_id as prop1_4_, properties2_.prop_id as prop1_1_1_, properties2_.foreign_id as foreign2_1_1_, properties2_.id_type as id3_1_1_ from public.service servicet0_ left outer join public.service servicet1_ on servicet0_.parent_service_id=servicet1_.service_id left outer join properties properties2_ on servicet1_.service_id=properties2_.foreign_id and properties.id_type = 'service' where servicet0_.service_id=?]
org.postgresql.util.PSQLException: ERROR: JOIN/ON clause refers to "properties", which is not part of JOIN
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1471)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1256)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:175)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:389)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:330)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:240)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:891)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:859)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
at org.hibernate.type.EntityType.resolve(EntityType.java:303)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1129)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at cz.active24.central.Test.main(Test.java:42)
08.02.06 14:36:45,023 WARN org.hibernate.util.JDBCExceptionReporter SQL Error: 0, SQLState: 42P10
08.02.06 14:36:45,023 ERROR org.hibernate.util.JDBCExceptionReporter ERROR: JOIN/ON clause refers to "properties", which is not part of JOIN
08.02.06 14:36:45,023 INFO org.hibernate.event.def.DefaultLoadEventListener Error performing load command
org.hibernate.exception.SQLGrammarException: could not load an entity: [cz.test.ServiceT#1]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1799)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:891)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:859)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
at org.hibernate.type.EntityType.resolve(EntityType.java:303)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1129)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at cz.active24.central.Test.main(Test.java:42)
Caused by: org.postgresql.util.PSQLException: ERROR: JOIN/ON clause refers to "properties", which is not part of JOIN
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1471)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1256)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:175)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:389)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:330)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:240)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
... 25 more
08.02.06 14:36:45,039 DEBUG org.hibernate.transaction.JDBCTransaction rollback
08.02.06 14:36:45,039 DEBUG org.hibernate.transaction.JDBCTransaction rolled back JDBC Connection
08.02.06 14:36:45,039 DEBUG org.hibernate.jdbc.JDBCContext after transaction completion
08.02.06 14:36:45,039 DEBUG org.hibernate.jdbc.ConnectionManager aggressively releasing JDBC connection
08.02.06 14:36:45,039 DEBUG org.hibernate.jdbc.ConnectionManager releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
08.02.06 14:36:45,039 DEBUG org.hibernate.connection.DriverManagerConnectionProvider returning connection to pool, pool size: 1
08.02.06 14:36:45,039 DEBUG org.hibernate.impl.SessionImpl after transaction completion
08.02.06 14:36:45,054 DEBUG org.hibernate.impl.SessionImpl closing session
08.02.06 14:36:45,054 DEBUG org.hibernate.jdbc.ConnectionManager connection already null in cleanup : no action