[Hibernate-JIRA] Created: (HHH-2883) ManyToMany doesn't work with polymorfism
by Dirk (JIRA)
ManyToMany doesn't work with polymorfism
----------------------------------------
Key: HHH-2883
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2883
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.4
Environment: Hibernate 3.2.4, Annotations 3.3.0, Entitymanager 3.3.0
Reporter: Dirk
We tried out the SingleTable inheritance with a ManyToMany
@Entity
@Table(name="SHB_PRINCIPAL")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="TYPE",discriminatorType=DiscriminatorType.INTEGER)
@Cache(usage=CacheConcurrencyStrategy.TRANSACTIONAL)
public class Principal implements Serializable {
....
@Entity
@DiscriminatorValue(PrincipalType.USER_NR)
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class ApplicationUser extends Principal {
private static final long serialVersionUID = 1L;
@ManyToMany(fetch=FetchType.LAZY, cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH},
targetEntity=Role.class)
@JoinTable(name="SHB_PRINCIPAL_TO_PRINCIPAL",
joinColumns=@JoinColumn(name="FROM_PRINCIPAL_ID"),
inverseJoinColumns=@JoinColumn(name="TO_PRINCIPAL_ID"))
private Set<Role> roles;
@ManyToMany(fetch=FetchType.LAZY, cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH},
targetEntity=ApplicationGroup.class)
@JoinTable(name="SHB_PRINCIPAL_TO_PRINCIPAL",
joinColumns=@JoinColumn(name="FROM_PRINCIPAL_ID"),
inverseJoinColumns=@JoinColumn(name="TO_PRINCIPAL_ID"))
private Set<ApplicationGroup> groups;
@Entity
@DiscriminatorValue(PrincipalType.GROUP_NR)
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class ApplicationGroup extends Principal {
private static final long serialVersionUID = 1L;
@ManyToMany(fetch=FetchType.LAZY, cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
@JoinTable(name="SHB_PRINCIPAL_TO_PRINCIPAL",
joinColumns=@JoinColumn(name="TO_PRINCIPAL_ID"),
inverseJoinColumns=@JoinColumn(name="FROM_PRINCIPAL_ID"))
private Set<ApplicationUser> users;
public ApplicationGroup() {
super();
this.type = PrincipalType.GROUP;
}
public Set<ApplicationUser> getUsers() {
return users;
}
public void setUsers(Set<ApplicationUser> users) {
this.users = users;
}
}
But in the groups and the roles of the user, hibernate returns all principals, not only the users or groups. In the query it's clear that the descriminator is NOT used.
--
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, 6 months
[Hibernate-JIRA] Created: (EJB-360) Create a property to intercept the Configuration for programmatic modification before the EntityManagerFactory is created
by John Leach (JIRA)
Create a property to intercept the Configuration for programmatic modification before the EntityManagerFactory is created
-------------------------------------------------------------------------------------------------------------------------
Key: EJB-360
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-360
Project: Hibernate Entity Manager
Issue Type: New Feature
Components: EntityManager
Affects Versions: 3.3.2.GA
Reporter: John Leach
Attachments: ConfigurationCustomizer.patch
Create a property (hibernate.cfg.customizer) in persistence.xml which allows the user to specify a class which can programmatically modify the constructed Configuration object (built via annotations and XML configuration) before the EntityManagerFactory is created.
The aim is to provide a third mechanism for configuration, after annotation and XML configuration has been performed. By specifying a user supplied class name the user can then use Configuration methods to access the mappings and make programmatic modifications, such as converting Cascade.ALL (JPA) to cascade all-delete-orphans (Hibernate).
The attached patch provides the code modifications, currently used in Spikes, (http://lab.jugtorino.it/trac/sandbox/wiki/Spikes) to allow programmatic modifications of the Configuration object. The patch file was created from the current trunk (18/05/2008) of hibernate-entitymanager, more specifically, trunk/src/java/org/hibernate/ejb.
The user supplied class must have a no argument constructor, and implement the org.hibernate.ejb.ConfigurationCustomizer interface.
The mechanism is similar to hibernate.ejb.interceptor in concept, except that it acts on the Configuration object rather than on the entity life cycle.
--
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, 6 months
[Hibernate-JIRA] Created: (HHH-2254) A query validation bug produces QueryException: "Expected positional parameter count: 1, actual parameters: [Parent@bec357b] [from Child this where this.id.parent = ?]"
by Hernan Liendo (JIRA)
A query validation bug produces QueryException: "Expected positional parameter count: 1, actual parameters: [Parent@bec357b] [from Child this where this.id.parent = ?]"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-2254
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2254
Project: Hibernate3
Type: Bug
Components: query-hql
Versions: 3.2.0.ga
Environment: Hibernate 3.2 using Sybase. However this is not an environment caused problem. It's supposed to happen in every environment.
Reporter: Hernan Liendo
-- Short description ============================================================================ --
A query validation bug produces QueryException: "Expected positional parameter count: 1, actual parameters: [Parent@bec357b] [from Child this where this.id.parent = ?].
Both Parent and Child use composite keys.
-- Context ====================================================================================== --
Having composite keys for a Parent class and a Child class, I want to retrieve childs that belong to an specific Parent.
-- Parent Definition ============================================================================ --
public class Parent {
public ParentId ParentId;
...
}
public class ParentId {
private String idField1;
private int idField2;
...
}
// the parent mapping
<hibernate-mapping>
<class mutable="false" table="xx" name="Parent">
<composite-id class="ParentId" access="field" name="parentId">
<key-property column="idField1" access="field" name="idField1"/>
<key-property column="idField2" access="field" name="idField2"/>
</composite-id>
</class>
</hibernate-mapping>
-- Child Definition ============================================================================ --
public class Child {
public ChildId childId;
...
}
public class ChildId {
public Parent parent;
public String aditionalIdField;
...
}
// the mapping
<hibernate-mapping>
<class mutable="false" table="yyy" name="Child">
<composite-id class="ChildId" access="field" name="childId">
<key-many-to-one name="parent" class="Parent" access="field">
<column name="idField1" not-null="true" />
<column name="idField2" not-null="true" />
</key-many-to-one>
<key-property column="aditionalIdField" access="field" name="aditionalIdField"/>
</composite-id>
</class>
</hibernate-mapping>
-- HQL Statement ============================================================================ --
from Child this where this.childId.parent = ?
or
from Child this where this.id.parent = ? // using aliased id
-- The Exception ============================================================================ --
org.hibernate.QueryException: Expected positional parameter count: 1, actual parameters: [Parent@bec357b] [from Child this where this.childId.parent = ?]
at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryImpl.java:319)
at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryImpl.java:275)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:75)
...
-- The Problem ============================================================================ --
class: org.hibernate.impl.AbstractQueryImpl
method: protected void verifyParameters(boolean reserveFirstParameter) throws HibernateException
line: 286
The method validates parameters. It resolves the "positionalValueSpan" variable witch in my case gets the value of 2 (One for parent's idField1 and the other for parent's idField2).
The method compares positionalValueSpan (2) with parameterMetadata.getOrdinalParameterCount() witch it is 1 (the quantity of "?" signs in the HQL statement".
This bug only happens when:
1. composed keys are used (and)
2. having a parent-child relationship (and)
3. resolving children from certain parent.
-- Hibernate user workaround ============================================================================ --
Not to use a parent instance variable in the Child class.
Hope this helps. If you guys need the source code in order to check the bug, please let me know it. Good luck!
Hernan
--
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, 6 months
[Hibernate-JIRA] Created: (EJB-287) Upload 3.3.1.GA to the Maven repository
by Aleksei Valikov (JIRA)
Upload 3.3.1.GA to the Maven repository
---------------------------------------
Key: EJB-287
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-287
Project: Hibernate Entity Manager
Issue Type: Improvement
Components: EntityManager
Affects Versions: 3.3.1.GA
Reporter: Aleksei Valikov
Priority: Minor
Attachments: hibernate-entitymanager-3.3.1.ga.pom
Would you please upload the entity manager as well as dependent artifacts to the Maven repository?
This is quite important for Maven builds.
Dependent artifacts are:
hibernate-commons-annotations (3.0.0.ga)
hibernate-validator (3.0.0.ga)
jboss-archive-browsing (2.0.2.alpha)
Below are the commands I used to deploy these artifacts, I hope this helps.
I also attach the POM file for the entity manager. I hope you could reuse it in further versions.
Thank you!
mvn deploy:deploy-file -DgroupId=org.hibernate -DartifactId=hibernate-entitymanager -Dversion=3.3.1.ga -Dpackaging=jar -Dfile=hibernate-entitymanager-3.3.1.ga.jar -DpomFile=hibernate-entitymanager-3.3.1.ga.pom -Durl=file://C:/Projects/p2.external/maven2-repository/www/repository
mvn deploy:deploy-file -DgroupId=org.hibernate -DartifactId=hibernate-commons-annotations -Dversion=3.0.0.ga -Dpackaging=jar -Dfile=hibernate-commons-annotations-3.0.0.ga.jar -Durl=file://C:/Projects/p2.external/maven2-repository/www/repository
mvn deploy:deploy-file -DgroupId=org.hibernate -DartifactId=hibernate-validator -Dversion=3.0.0.ga -Dpackaging=jar -Dfile=hibernate-validator-3.0.0.ga.jar -Durl=file://C:/Projects/p2.external/maven2-repository/www/repository
mvn deploy:deploy-file -DgroupId=jboss -DartifactId=jboss-archive-browsing -Dversion=2.0.2.alpha -Dpackaging=jar -Dfile=jboss-archive-browsing-2.0.2.alpha.jar -Durl=file://C:/Projects/p2.external/maven2-repository/www/repository
--
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, 6 months
[Hibernate-JIRA] Created: (HHH-3177) SetMaxResults with db2 database problem
by Irena (JIRA)
SetMaxResults with db2 database problem
---------------------------------------
Key: HHH-3177
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3177
Project: Hibernate3
Issue Type: Bug
Components: core
Environment: hibernate3.2.0.ga, DB2 8.2.1
Reporter: Irena
Trying to do simple thing:
List<Subject> subjects = (List<Subject>) currSession.createQuery("from Subject").setMaxResults(10).list();
this prings fallowing:
WARN JDBCExceptionReporter:71 - SQL Error: -104, SQLState: 42601
ERROR JDBCExceptionReporter:72 - DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, SQLERRMC: 10;select top ;.
WARN JDBCExceptionReporter:71 - SQL Error: -727, SQLState: 56098
ERROR JDBCExceptionReporter:72 - DB2 SQL error: SQLCODE: -727, SQLSTATE: 56098, SQLERRMC: 2;-104;42601;10|select top |.
WARN JDBCExceptionReporter:71 - SQL Error: -727, SQLState: 56098
ERROR JDBCExceptionReporter:72 - DB2 SQL error: SQLCODE: -727, SQLSTATE: 56098, SQLERRMC: 2;-104;42601;10|select top |.
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2147)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028)
at org.hibernate.loader.Loader.list(Loader.java:2023)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:393)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at ru.nbch.quality.logic.ReportProcessor.main(ReportProcessor.java:66)
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:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Caused by: com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, SQLERRMC: 10;select top ;.
at com.ibm.db2.jcc.b.id.e(id.java:1640)
at com.ibm.db2.jcc.b.id.a(id.java:1229)
at com.ibm.db2.jcc.c.fb.h(fb.java:149)
at com.ibm.db2.jcc.c.fb.a(fb.java:43)
at com.ibm.db2.jcc.c.s.a(s.java:30)
at com.ibm.db2.jcc.c.wb.g(wb.java:152)
at com.ibm.db2.jcc.b.id.n(id.java:1209)
at com.ibm.db2.jcc.b.jd.eb(jd.java:1779)
at com.ibm.db2.jcc.b.jd.a(jd.java:2232)
at com.ibm.db2.jcc.b.jd.V(jd.java:505)
at com.ibm.db2.jcc.b.jd.executeQuery(jd.java:488)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1668)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2144)
... 13 more
--
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, 6 months
[Hibernate-JIRA] Created: (EJB-308) Space in path result in error durring deployment
by Max Rydahl Andersen (JIRA)
Space in path result in error durring deployment
------------------------------------------------
Key: EJB-308
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-308
Project: Hibernate Entity Manager
Issue Type: Bug
Components: EntityManager
Affects Versions: 3.2.1
Environment: both linux and windows, JBoss EAP 4.2 or JBoss 4.2
Reporter: Max Rydahl Andersen
Assignee: Emmanuel Bernard
Priority: Critical
16:38:05,991 ERROR [[/test]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
javax.persistence.PersistenceException: java.lang.IllegalArgumentException: Unable to visit JAR file:/home/max/rh devstudio/jboss-eap/jboss-as/server/default/deploy/test.war/WEB-INF/classes. Cause: Illegal character in path at index 17: file:/home/max/rh devstudio/jboss-eap/jboss-as/server/default/deploy/test.war/WEB-INF/classes
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:252)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
at org.jboss.seam.core.EntityManagerFactory.startup(EntityManagerFactory.java:74)
When testing JBoss EAP 4.2 with RHDS I we created http://jira.jboss.org/jira/browse/JBIDE-691
and this is with Hibernate Annotations 3.2.1 which should have this one fixed according what i could find (i'll link to it)
--
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, 6 months