[Hibernate-JIRA] Resolved: (HHH-1697) OracleDialect fails to recognize sequence accessible through syonyms when validating schema
by Diego Plentz (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1697?page=c... ]
Diego Plentz resolved HHH-1697.
-------------------------------
Resolution: Fixed
Fix Version/s: 3.4
> OracleDialect fails to recognize sequence accessible through syonyms when validating schema
> -------------------------------------------------------------------------------------------
>
> Key: HHH-1697
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1697
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.3.0.CR1
> Environment: Hibernate 3.1.2, Hibernate 3.1.3 Oracle 10g
> Reporter: Bjørn Bjerkeli
> Assignee: Diego Plentz
> Priority: Minor
> Fix For: 3.4
>
> Attachments: Oracle9Dialect.java
>
>
> The Dialect implementations in OracleDialect and Oracle9Dialect fails to recognize sequences upon validation when they are accesssed through synonyms
> because the user_sequences table will not create when the sequence is acced through a synonym. This is needed when using hibernate.hbm2ddl.auto=validate
> which is a very useful feature.
> Thus sequences returned by:
> public String getQuerySequencesString() {
> return "select sequence_name from user_sequences";
> }
> will mot identify sequences accessible using a synonym.
> By using this implementation:
> public String getQuerySequencesString() {
> return "select sequence_name from user_sequences " +
> "union " +
> "select synonym_name from user_synonyms us " +
> "where exists (select 1 from all_objects ao where object_type='SEQUENCE' and " +
> "us.table_name = ao.object_name)";
> }
> orale will also return sequences acccessible though synonyms.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
17 years, 9 months
[Hibernate-JIRA] Commented: (HHH-1523) LazyInitializationError on enabling query cache...
by jazir malik (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1523?page=c... ]
jazir malik commented on HHH-1523:
----------------------------------
This is a very long-standing issue. Is there any chance of a resolution soon, or even assigning it to somebody?
> LazyInitializationError on enabling query cache...
> --------------------------------------------------
>
> Key: HHH-1523
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1523
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.0.5, 3.1
> Environment: 3.0.1 and 3.1, HSQLDB and Oracle
> Reporter: Vikas Sasidharan
> Attachments: cache_issue.log, QueryCacheIssue.zip
>
>
> I have two domain objects - Employee and Department - and there is a 1:N relationship from Department to Employee. When I join fetch an Employee with its Department, without query cache enabled, it works fine. If I enable query cache for this same query, it bombs with a LazyInitializationException.
> Notes:
> 1) We get this error only if query cache is enabled.
> 2) We observed the same behaviour on both oscache and ehcache
> 3) Calling Hibernate.initialize() explicitly after firing the HQL seems to work. The initialization does not fire an extra query though (it seems to pick it from the cache).
> 4) Setting "lazy=false" on the "many-to-one" mapping also works. However, it wouldn't be acceptable.
> Hibernate version: 3.0.5
> Mapping documents:
> Employee.hbm.xml
> <hibernate-mapping>
> <class name="tavant.platform.test.domain.Employee"
> table="CACHE_ISSUE_EMP" lazy="true" dynamic-update="true" dynamic-insert="true">
> <cache usage="read-write" />
> <id name="id" column="EMP_ID" type="java.lang.Long"
> access="field" unsaved-value="null">
> <generator class="increment" />
> </id>
>
> <property name="name" type="string" update="true"
> insert="true" column="EMP_NAME"/>
> <many-to-one name="department" class="tavant.platform.test.domain.Department"
> cascade="none" outer-join="auto" update="true" insert="true" column="DEPARTMENT_ID"/>
> </class>
> </hibernate-mapping>
>
> Department.hbm.xml
> <hibernate-mapping>
> <class name="tavant.platform.test.domain.Department" table="CACHE_ISSUE_DEP"
> lazy="true" dynamic-update="true" dynamic-insert="true">
>
> <cache usage="read-write" />
> <id name="id" column="DEPARTMENT_ID"
> type="java.lang.Long" access="field">
> <generator class="increment"/>
> </id>
> <property name="name" type="java.lang.String"
> update="false" insert="true" column="NAME"/>
> <bag name="employees" lazy="true"
> inverse="true" cascade="save-update" access="field">
> <cache usage="read-write"/>
> <key column="DEPARTMENT_ID"/>
> <one-to-many class="tavant.platform.test.domain.Employee"/>
> </bag>
> </class>
> </hibernate-mapping>
>
> Code between sessionFactory.openSession() and session.close():
> public Employee getEmployeeWithDepartment(String empName) {
> Session session = null;
> try {
> session = sessionFactory.openSession();
> Employee emp = (Employee) session.createQuery(
> "from Employee e join fetch e.department where e.name = :name")
> .setString("name", empName)
> .setCacheable(true)
> .uniqueResult();
> // If I uncomment the next line, this works (even without
> // firing an extra query)!
> // Hibernate.initialize(emp.getDepartment());
> return emp;
> } finally {
> if (session != null) {
> session.close();
> }
> }
> }
>
> // First load employee and populate cahces
> Employee emp = test.getEmployeeWithDepartment(EMPLOYEE_NAME);
> System.out.println("Employee : " + emp + ", Employee.Department : "
> + emp.getDepartment());
>
> // Now try to make use of the cache
> emp = test.getEmployeeWithDepartment(EMPLOYEE_NAME);
> System.out.println("Employee : " + emp + ", Employee.Department : "
> + emp.getDepartment());
>
> Full stack trace of any exception that occurs:
> org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
> at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:53)
> at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:84)
> at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
> at tavant.platform.test.domain.Department$$EnhancerByCGLIB$$67b26899.toString(<generated>)
> at java.lang.String.valueOf(String.java:2131)
> at java.lang.StringBuffer.append(StringBuffer.java:370)
> at tavant.platform.test.client.TestPrefetchRelationWithQueryCacheEnabled.main(TestPrefetchRelationWithQueryCacheEnabled.java:116)
>
> Name and version of the database you are using:
> We have noticed this on Oracle and HSQL
> The generated SQL (show_sql=true):
> #First read, goes fine
> Hibernate: select employee0_.EMP_ID as EMP1_0_, department1_.DEPARTMENT_ID as DEPARTMENT1_1_, employee0_.EMP_NAME as EMP2_1_0_, employee0_.DEPARTMENT_ID as DEPARTMENT3_1_0_, department1_.NAME as NAME0_1_ from CACHE_ISSUE_EMP employee0_ inner join CACHE_ISSUE_DEP department1_ on employee0_.DEPARTMENT_ID=department1_.DEPARTMENT_ID where (employee0_.EMP_NAME=? )
> #Prints the Employee and Department fine
> Employee : [Id : 1, name : testEmployee], Employee.Department : [Id : 1, name : testDepartment]
> #Second read bombs!
> org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
> at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:53)
> at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:84)
> at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
> [..]
> Please have a look at the post [http://forum.hibernate.org/viewtopic.php?t=955839] for more details and follow ups.
> Kindly help. I am attaching an Eclipse Project containing the TestCase. The main file is TestPrefetchRelationWithQueryCacheEnabled.
> Thanks,
> Vikas
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
17 years, 9 months
[Hibernate-JIRA] Commented: (HHH-1015) Incorrect SQL generated when one-to-many foreign key is in a discriminated subclass table
by Krasimir Chobantonov (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1015?page=c... ]
Krasimir Chobantonov commented on HHH-1015:
-------------------------------------------
I do have the same problem using Hibernate 3.2.6 when I'm using HBM file - when I use Hibernate annotations I don't have the problem - I guess that Hibernate Core does support that but there may be some differences between HBM and Annotation configurations.
> Incorrect SQL generated when one-to-many foreign key is in a discriminated subclass table
> -----------------------------------------------------------------------------------------
>
> Key: HHH-1015
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1015
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1 beta 2
> Environment: Hibernate versions 3.1 beta 3 and 3.0.5
> Reporter: Steven Grimm
> Priority: Minor
>
> I have the following mappings describing a hierarchy of events and a class that the events refer to:
> <hibernate-mapping package="com.xyz">
> <class name="Event" table="event" discriminator-value="-1">
> <id name="Id" type="long" column="event_id"/>
> <discriminator column="event_type_id" type="integer" />
> <subclass name="EventPayer" discriminator-value="-3">
> <join table="event_payer">
> <key column="event_id" />
> <many-to-one name="payer" column="payer_id" class="Payer" />
> </join>
> <subclass name="EventPayerCreated" discriminator-value="1" />
> </subclass>
> </class>
> <class name="Payer" table="payer">
> <id name="payerId" column="payer_id" type="java.lang.Long"/>
> <set name="eventPayers" inverse="true" cascade="save-update">
> <key column="payer_id"/>
> <one-to-many class="EventPayer"/>
> </set>
> </class>
> </hibernate-mapping>
> When I fetch the Payer.eventPayers collection, Hibernate generates this SQL:
> select eventpayer0_.payer_id as payer7_1_,
> eventpayer0_.event_id as event1_1_,
> eventpayer0_.event_id as event1_5_0_,
> eventpayer0_1_.payer_id as payer2_6_0_,
> eventpayer0_.event_type_id as event2_5_0_
> from event eventpayer0_
> inner join event_payer eventpayer0_1_
> on eventpayer0_.event_id=eventpayer0_1_.event_id
> where eventpayer0_.payer_id=?
> The problem is that there is no event.payer_id column; payer_id is in the child table, not the parent. It appears that specifying a discriminated subclass in <one-to-many> is the same as specifying the superclass, or that Hibernate is ignoring the subclass's <join> element. As far as I can tell, this leaves no way to resolve bidirectional associations where one end of the association is in a discriminated subclass, which seems like a perfectly reasonable thing to want to do.
> I also tried changing <key column="payer_id"/> to <key property-ref="payer"/> in the Payer class's <set> element, but got similar behavior in the form of a "property not found" error: Hibernate is either looking in the superclass's properties rather than the subclass's or is ignoring the list of properties in the <join> element.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
17 years, 9 months
[Hibernate-JIRA] Created: (EJB-371) Hibernate dose not support the single-table inheritance strategy for relational entities
by louie (JIRA)
Hibernate dose not support the single-table inheritance strategy for relational entities
----------------------------------------------------------------------------------------
Key: EJB-371
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-371
Project: Hibernate Entity Manager
Issue Type: Bug
Components: EntityManager
Affects Versions: 3.4.0.CR1
Environment: hibernate-annotations-3.4.0.CR1, hibernate-conmmons-annotations-3.1.0.CR1,hibernate-tools-3.2.0.GA
Reporter: louie
Attachments: test-case.zip
Hibernate EJB configuration failed in the case of single-table inheritance strategy for relational entities. Here is the use case:
@Entity
public class User {
@Id
@SequenceGenerator(name = "user", sequenceName = "user_id")
@GeneratedValue(generator = "user")
private int id;
private String name;
@OneToMany(mappedBy = "user")
private List<ExcludedGroupUser> excludedUsers;
@OneToMany(mappedBy = "user")
private List<IncludedGroupUser> includedUsers;
...
}
@Entity
public class Group {
@Id
@SequenceGenerator(name = "group", sequenceName = "group_id")
@GeneratedValue(generator = "group")
private int id;
private String name;
@ManyToOne(fetch = FetchType.EAGER)
private Group underlying;
/** list of user belong to underlying group, but not belongs to this group */
@OneToMany(mappedBy = "group")
private List<ExcludedGroupUser> excludedUsers;
/** list of user belong to this group **/
@OneToMany(mappedBy = "group")
private List<IncludedGroupUser> includedUsers;
...
}
The main relational entity:
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="groupType",discriminatorType=DiscriminatorType.STRING, length=1)
public class GroupUser {
@Id
@SequenceGenerator(name = "groupUser", sequenceName = "groupUser_id")
@GeneratedValue(generator = "groupUser")
private int id;
@ManyToOne
private Group group;
@ManyToOne
private User user;
...
}
The subclasses:
@Entity
@DiscriminatorValue("I")
public class IncludedGroupUser extends GroupUser{
}
and
@Entity
@DiscriminatorValue("E")
public class ExcludedGroupUser extends GroupUser {
}
The build output error message:
C:\workspaces\test-case\test-case>ant -verbose
Apache Ant version 1.6.5 compiled on June 2 2005
Buildfile: build.xml
Detected Java version: 1.5 in: C:\Program Files\Java\jdk1.6.0_05\jre
Detected OS: Windows XP
parsing buildfile C:\workspaces\test-case\test-case\build.xml with URI = file:///C:/workspaces/test-
case/test-case/build.xml
Project base dir set to: C:\workspaces\test-case\test-case
Build sequence for target(s) `compile' is [clean, copy-resources, compile]
Complete build sequence is [clean, copy-resources, compile, ]
clean:
[delete] Deleting directory C:\workspaces\test-case\test-case\bin
[delete] Deleting C:\workspaces\test-case\test-case\bin\META-INF\persistence.xml
[delete] Deleting directory C:\workspaces\test-case\test-case\bin\META-INF
[delete] Deleting C:\workspaces\test-case\test-case\bin\notWorking\ExcludedGroupUser.class
[delete] Deleting C:\workspaces\test-case\test-case\bin\notWorking\Group.class
[delete] Deleting C:\workspaces\test-case\test-case\bin\notWorking\GroupUser.class
[delete] Deleting C:\workspaces\test-case\test-case\bin\notWorking\IncludedGroupUser.class
[delete] Deleting C:\workspaces\test-case\test-case\bin\notWorking\User.class
[delete] Deleting directory C:\workspaces\test-case\test-case\bin\notWorking
[delete] Deleting C:\workspaces\test-case\test-case\bin\working\Employee.class
[delete] Deleting C:\workspaces\test-case\test-case\bin\working\FullTimeEmployee.class
[delete] Deleting C:\workspaces\test-case\test-case\bin\working\PartTimeEmployee.class
[delete] Deleting directory C:\workspaces\test-case\test-case\bin\working
[delete] Deleting directory C:\workspaces\test-case\test-case\bin
[mkdir] Created dir: C:\workspaces\test-case\test-case\bin
copy-resources:
[copy] META-INF\persistence.xml added as META-INF/persistence.xml doesn't exist.
[copy] omitted as is up to date.
[copy] META-INF added as META-INF doesn't exist.
[copy] notWorking added as notWorking doesn't exist.
[copy] working added as working doesn't exist.
[copy] Copying 1 file to C:\workspaces\test-case\test-case\bin
[copy] Copying C:\workspaces\test-case\test-case\src\META-INF\persistence.xml to C:\workspaces\
test-case\test-case\bin\META-INF\persistence.xml
[copy] Copied 3 empty directories to 2 empty directories under C:\workspaces\test-case\test-cas
e\bin
compile:
[javac] META-INF\persistence.xml skipped - don't know how to handle it
[javac] notWorking\ExcludedGroupUser.java added as notWorking/ExcludedGroupUser.class doesn't ex
ist.
[javac] notWorking\Group.java added as notWorking/Group.class doesn't exist.
[javac] notWorking\GroupUser.java added as notWorking/GroupUser.class doesn't exist.
[javac] notWorking\IncludedGroupUser.java added as notWorking/IncludedGroupUser.class doesn't ex
ist.
[javac] notWorking\User.java added as notWorking/User.class doesn't exist.
[javac] working\Employee.java added as working/Employee.class doesn't exist.
[javac] working\FullTimeEmployee.java added as working/FullTimeEmployee.class doesn't exist.
[javac] working\PartTimeEmployee.java added as working/PartTimeEmployee.class doesn't exist.
[javac] Compiling 8 source files to C:\workspaces\test-case\test-case\bin
[javac] Using modern compiler
[javac] Compilation arguments:
[javac] '-d'
[javac] 'C:\workspaces\test-case\test-case\bin'
[javac] '-classpath'
[javac] 'C:\workspaces\test-case\test-case\bin;C:\workspaces\test-case\test-case\lib\antlr-2.7.6
.jar;C:\workspaces\test-case\test-case\lib\commons-collections-3.1.jar;C:\workspaces\test-case\test-
case\lib\commons-logging-1.1.1.jar;C:\workspaces\test-case\test-case\lib\dom4j-1.6.1.jar;C:\workspac
es\test-case\test-case\lib\freemarker.jar;C:\workspaces\test-case\test-case\lib\hibernate-annotation
s.jar;C:\workspaces\test-case\test-case\lib\hibernate-commons-annotations.jar;C:\workspaces\test-cas
e\test-case\lib\hibernate-entitymanager.jar;C:\workspaces\test-case\test-case\lib\hibernate-tools.ja
r;C:\workspaces\test-case\test-case\lib\hibernate3.jar;C:\workspaces\test-case\test-case\lib\javassi
st-3.6.0.GA.jar;C:\workspaces\test-case\test-case\lib\jboss-archive-browsing.jar;C:\workspaces\test-
case\test-case\lib\log4j-1.2.15.jar;C:\workspaces\test-case\test-case\lib\ojdbc14.jar;C:\workspaces\
test-case\test-case\lib\persistence-api.jar;C:\workspaces\test-case\test-case\lib\slf4j-api-1.4.2.ja
r;C:\workspaces\test-case\test-case\lib\slf4j-log4j12-1.5.2.jar;C:\apache-ant-1.6.5\lib\ant-launcher
.jar;C:\workspaces\test-case\test-case;C:\Program Files\Java\jre1.6.0_05\lib\ext\QTJava.zip;C:\apach
e-ant-1.6.5\lib\ant-antlr.jar;C:\apache-ant-1.6.5\lib\ant-apache-bcel.jar;C:\apache-ant-1.6.5\lib\an
t-apache-bsf.jar;C:\apache-ant-1.6.5\lib\ant-apache-log4j.jar;C:\apache-ant-1.6.5\lib\ant-apache-oro
.jar;C:\apache-ant-1.6.5\lib\ant-apache-regexp.jar;C:\apache-ant-1.6.5\lib\ant-apache-resolver.jar;C
:\apache-ant-1.6.5\lib\ant-commons-logging.jar;C:\apache-ant-1.6.5\lib\ant-commons-net.jar;C:\apache
-ant-1.6.5\lib\ant-icontract.jar;C:\apache-ant-1.6.5\lib\ant-jai.jar;C:\apache-ant-1.6.5\lib\ant-jav
amail.jar;C:\apache-ant-1.6.5\lib\ant-jdepend.jar;C:\apache-ant-1.6.5\lib\ant-jmf.jar;C:\apache-ant-
1.6.5\lib\ant-jsch.jar;C:\apache-ant-1.6.5\lib\ant-junit.jar;C:\apache-ant-1.6.5\lib\ant-netrexx.jar
;C:\apache-ant-1.6.5\lib\ant-nodeps.jar;C:\apache-ant-1.6.5\lib\ant-starteam.jar;C:\apache-ant-1.6.5
\lib\ant-stylebook.jar;C:\apache-ant-1.6.5\lib\ant-swing.jar;C:\apache-ant-1.6.5\lib\ant-trax.jar;C:
\apache-ant-1.6.5\lib\ant-vaj.jar;C:\apache-ant-1.6.5\lib\ant-weblogic.jar;C:\apache-ant-1.6.5\lib\a
nt-xalan1.jar;C:\apache-ant-1.6.5\lib\ant-xslp.jar;C:\apache-ant-1.6.5\lib\ant.jar;C:\apache-ant-1.6
.5\lib\jaxws-tools.jar;C:\apache-ant-1.6.5\lib\xercesImpl.jar;C:\apache-ant-1.6.5\lib\xml-apis.jar;C
:\Program Files\Java\jdk1.6.0_05\lib\tools.jar'
[javac] '-sourcepath'
[javac] 'C:\workspaces\test-case\test-case\src'
[javac] '-g:none'
[javac]
[javac] The ' characters around the executable and arguments are
[javac] not part of the command.
[javac] Files to be compiled:
[javac] C:\workspaces\test-case\test-case\src\notWorking\ExcludedGroupUser.java
[javac] C:\workspaces\test-case\test-case\src\notWorking\Group.java
[javac] C:\workspaces\test-case\test-case\src\notWorking\GroupUser.java
[javac] C:\workspaces\test-case\test-case\src\notWorking\IncludedGroupUser.java
[javac] C:\workspaces\test-case\test-case\src\notWorking\User.java
[javac] C:\workspaces\test-case\test-case\src\working\Employee.java
[javac] C:\workspaces\test-case\test-case\src\working\FullTimeEmployee.java
[javac] C:\workspaces\test-case\test-case\src\working\PartTimeEmployee.java
Property ${libraries} has not been set
[hibernatetool] Executing Hibernate Tool with a JPA Configuration
dropping C:\workspaces\test-case\test-case\${libraries} from path as it doesn't exist
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
[hibernatetool] log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Ver
sion).
[hibernatetool] log4j:WARN Please initialize the log4j system properly.
[hibernatetool] An exception occurred while running exporter #2:hbm2ddl (Generates database schema)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] Problems in creating a configuration for JPA. Have you remembered to add hibernate E
ntityManager jars to the classpath ?
[hibernatetool] java.lang.reflect.InvocationTargetException
[hibernatetool] javax.persistence.PersistenceException: org.hibernate.AnnotationException: mappedBy
reference an unknown target entity property: notWorking.ExcludedGroupUser.user in notWorking.User.ex
cludedUsers
[hibernatetool] org.hibernate.AnnotationException: mappedBy reference an unknown target entity prope
rty: notWorking.ExcludedGroupUser.user in notWorking.User.excludedUsers
BUILD FAILED
C:\workspaces\test-case\test-case\build.xml:28: Problems in creating a configuration for JPA. Have y
ou remembered to add hibernate EntityManager jars to the classpath ?
at org.hibernate.tool.ant.JPAConfigurationTask.createConfiguration(JPAConfigurationTask.java
:57)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:54)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.tool.ant.JPAConfigurationTask.createConfiguration(JPAConfigurationTask.java
:43)
... 16 more
Caused by: javax.persistence.PersistenceException: org.hibernate.AnnotationException: mappedBy refer
ence an unknown target entity property: notWorking.ExcludedGroupUser.user in notWorking.User.exclude
dUsers
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:258)
... 21 more
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property:
notWorking.ExcludedGroupUser.user in notWorking.User.excludedUsers
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.
java:576)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:541)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1140)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:
319)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1125)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1269)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:150)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:888)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:186)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:246)
... 21 more
--- Nested Exception ---
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.tool.ant.JPAConfigurationTask.createConfiguration(JPAConfigurationTask.java
:43)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:54)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: javax.persistence.PersistenceException: org.hibernate.AnnotationException: mappedBy refer
ence an unknown target entity property: notWorking.ExcludedGroupUser.user in notWorking.User.exclude
dUsers
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:258)
... 21 more
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property:
notWorking.ExcludedGroupUser.user in notWorking.User.excludedUsers
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.
java:576)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:541)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1140)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:
319)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1125)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1269)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:150)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:888)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:186)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:246)
... 21 more
Total time: 2 seconds
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
17 years, 9 months
[Hibernate-JIRA] Created: (HBX-1075) Single table inhertance failed on hbm2ddl
by louie (JIRA)
Single table inhertance failed on hbm2ddl
-----------------------------------------
Key: HBX-1075
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-1075
Project: Hibernate Tools
Issue Type: Bug
Affects Versions: 3.2.1
Reporter: louie
We are reporting an issue during the database schema generating process using hbm2ddl tools against some entities using single-table inheritance strategy. It works fine for the simple hierarchy entity mappings. It breaks down when we try to modeling the data using single-table inheritance in relational entities. Here is one example:
The main object:
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorValue("S")
public class MySub1 extends AbstractMySuper {
@ManyToOne(fetch = FetchType.EAGER)
private MySub1 underlying;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy="mysub1")
private List<ExcludedMySub1> excludedSub1;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy="mysub1")
private List<IncludedMySub1> includedSub1;
...
}
The relationship super-class:
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="myType",discriminatorType=DiscriminatorType.STRING, length=1)
public abstract class AbstractMySub1 {
@Id
@SequenceGenerator(name = "AbstractMySub1", sequenceName = "AbstractMySub1_id")
@GeneratedValue(generator = "AbstractMySub1")
@Column(precision=5)
private int id;
@ManyToOne(cascade={CascadeType.PERSIST,CascadeType.MERGE, CascadeType.REFRESH})
private MySub1 mysub1;
...
}
The relationship sub-classes:
@Entity
@DiscriminatorValue("I")
public class IncludedMySub1 extends AbstractMySub1 {
}
@Entity
@DiscriminatorValue("E")
public class ExcludedMySub1 extends AbstractMySub1 {
}
I got the following error:
[hibernatetool] Problems in creating a configuration for JPA. Have you remembered to add hibernate EntityManager jars to the classpath ?
[hibernatetool] java.lang.reflect.InvocationTargetException
[hibernatetool] javax.persistence.PersistenceException: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: ExcludedMySub1.mysub1 in MySub1.excludedSub1
[hibernatetool] org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: ExcludedMySub1.mysub1 in MySub1.excludedSub1
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error executing ant tasks
Embedded error: Problems in creating a configuration for JPA. Have you remembered to add hibernate EntityManager jars to the classpath ?
mappedBy reference an unknown target entity property: ExcludedMySub1.mysub1 in MySub1.excludedSub1
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Error executing ant tasks
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:583)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error executing ant tasks
at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:114)
at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:83)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
... 16 more
Caused by: Problems in creating a configuration for JPA. Have you remembered to add hibernate EntityManager jars to the classpath ?
at org.hibernate.tool.ant.JPAConfigurationTask.createConfiguration(JPAConfigurationTask.java:57)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:54)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:64)
at net.sf.antcontrib.logic.IfTask.execute(IfTask.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:123)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:108)
... 19 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.tool.ant.JPAConfigurationTask.createConfiguration(JPAConfigurationTask.java:43)
... 36 more
Caused by: javax.persistence.PersistenceException: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: ExcludedMySub1.mysub1 in MySub1.excludedSub1
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:258)
... 41 more
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property:ExcludedMySub1.mysub1 in MySub1.excludedSub1
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:552)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:517)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1136)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:316)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1121)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1269)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:150)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:888)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:186)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:246)
... 41 more
[INFO] ------------------------------------------------------------------------
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
17 years, 9 months
[Hibernate-JIRA] Commented: (HHH-1928) order-by mapping for collections overrides order by in Criteria
by benoit heinrich (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1928?page=c... ]
benoit heinrich commented on HHH-1928:
--------------------------------------
Hi all,
Same problem occurs with the EJB3 annotation @OrderBy on a list.
Do we have any estimates when this bug will be fixed?
Thanks,
/Benoit
> order-by mapping for collections overrides order by in Criteria
> ---------------------------------------------------------------
>
> Key: HHH-1928
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1928
> Project: Hibernate3
> Issue Type: Bug
> Components: query-criteria
> Affects Versions: 3.2.0.cr3
> Reporter: Nguyen Hau Giang
> Attachments: testcase.zip
>
>
> relating to:
> HHH-594(order-by mapping for collections overrides order by in HQL)
> HHH-484(order-by not applied to collections fetched by OuterJoinLoader)
> Mapping(pseudo code):
> <class name="Master">
> <id name="id" />
> <set name="details" order-by="DISP_NO">
> <one-to-many class="Detail" />
> </set>
> </class>
> <class name="Detail">
> <id name="id" />
> <property name="dispNo" />
> <many-to-one name="master" class="Master" />
> </class>
> Same problem as in HHH-594, but instead of querying by HQL, when query by Criteria using join-fetch:
> session.createCriteria(Master.class)//
> .setFetchMode("details", FetchMode.JOIN)//
> .addOrder(Order.asc("id"))//
> .list();
> order-by mapping for collection overrides order by in Criteria:
> from
> Master this_
> left outer join
> Detail details2_
> on this_.id=details2_.ID
> order by
> details2_.DISP_NO,
> this_.id asc
> or when creating left-join alias:
> session.createCriteria(Master.class)//
> .createAlias("details", "D", Criteria.LEFT_JOIN)//
> .addOrder(Order.asc("id"))//
> .list();
> generated SQL:
> from
> Master this_
> left outer join
> Detail d1_
> on this_.id=d1_.ID
> order by
> d1_.DISP_NO,
> this_.id asc
> The order property specified in Criteria should be prior to order of collection mapping.
> I think this problem should be fixed as with HQL in HHH-594.
> For details, please see attached test case.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
17 years, 9 months
[Hibernate-JIRA] Commented: (HHH-892) HQL parser does not resolve alias in ORDER BY clause
by Ben Wong (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-892?page=co... ]
Ben Wong commented on HHH-892:
------------------------------
The workaround works only for simple query. For query such as:
select c.id,
c.customer,
(select count(s.totalSales) from sales s where s.customer = c and s.customerType = 4) as totalSales,
(select count(ex.totalExpense) from expenses ex where ex.customer = c and ex.customerType = 4) as totalExpenses
from customer c
order by totalSales / totalExpenses, c.id
The above is an example I made up, but that's what I am trying to do with my (more) complex HQL query. Unless I am wrong, I don't think you can stick subselect clauses in the order by.
P.S. I don't mean to whine, but how hard is it to replace the alias in the order by clause with the generated ones by Hibernate when generating the SQL from HQL? I would think this is a simple fix (or enhancement).
Ben
> HQL parser does not resolve alias in ORDER BY clause
> -----------------------------------------------------
>
> Key: HHH-892
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-892
> Project: Hibernate3
> Issue Type: Bug
> Components: query-hql
> Affects Versions: 3.0.5
> Environment: Hibernate 3.0.5, MySQL, Tomcat
> Reporter: Guido Laures
> Priority: Minor
>
> When using an alias for an ORDER BY clause this is not always correctly resolved. Example:
> SELECT SUM(A.x) AS mySum FROM MyClass AS A GROUP BY A.y ORDER BY mySum
> does not work because "mySum" is not resolved in the ORDER BY clause which results in an exception telling that mySum is an unknown column.
> Workaround (not to say "hack") is using:
> SELECT SUM(A.x) AS mySum FROM MyClass AS A GROUP BY A.y ORDER BY col_0_0_
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
17 years, 9 months