[Hibernate-JIRA] Created: (EJB-214) Native Query can not be used with parameter
by Shinpei Ohtani (JIRA)
Native Query can not be used with parameter
-------------------------------------------
Key: EJB-214
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-214
Project: Hibernate Entity Manager
Type: Bug
Components: EntityManager
Versions: 3.2.0.cr1
Environment: Hibernate EntityManager 3.2.0.cr1
Hibernate Core 3.2.0 cr2
Reporter: Shinpei Ohtani
When using Native Query with parameter, IndexOutOfBoundsException is occurred.
org.hibernate.engine.query.ParameterParser(Hibernate Core) handles positional parameter as named parameter internally,
but org.hibernate.ejb.QueryImpl(Hibernate EntityManager) expects positional(ordinal) parameter, not named parameter.
Here is sample for this issue.
=======
Query query = em.createNativeQuery("SELECT d.name FROM Department d WHERE d.id = ?1");
query.setParameter(1, 1);
=======
Result is
java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!
at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterDescriptor(ParameterMetadata.java:55)
at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterExpectedType(ParameterMetadata.java:61)
at org.hibernate.impl.AbstractQueryImpl.determineType(AbstractQueryImpl.java:389)
at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:369)
at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:198)
--
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
18 years, 4 months
[Hibernate-JIRA] Updated: (HHH-1401) session.merge() executes unnecessary updates when one-to-many relationship is defined.
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1401?page=all ]
Steve Ebersole updated HHH-1401:
--------------------------------
Fix Version: 3.2.1
Assign To: Steve Ebersole
> session.merge() executes unnecessary updates when one-to-many relationship is defined.
> --------------------------------------------------------------------------------------
>
> Key: HHH-1401
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1401
> Project: Hibernate3
> Type: Bug
> Components: core
> Versions: 3.1.1
> Environment: Hibernate 3.1.1
> Postgres 8.03
> Java 1.4.2_09
> Reporter: David Trott
> Assignee: Steve Ebersole
> Fix For: 3.2.1
> Attachments: HHH-1401.zip, Screenshot-Debug - AbstractPersistentCollection.class - Eclipse SDK .png, TEST-org.hibernate.test.optlock.OptimisticLockTest.txt
>
>
> I am attempting to use the session.merge() functionality in order to synchronize the state of the data coming from the web tier with the database, however I am seeing unnecessary updates (when nothing has changed).
> In order to track down the problem I created a test case with four tables and four classes (A,B,C and D)
> Where:
> A is the parent of B.
> B is the parent of C.
> C is the parent of D.
> And there are no other relationships present.
> All these relationships are bi-directional with the one-to-many side marked as inverse="true" and cascade="all-delete-orphan".
> The merge() is working fine (the data gets updated correctly) except that when there is no change to the data hibernate still runs updates on A,B and C however not on D (D has no one-to-many relationships).
> I am including the code and hibernate mapping for B as it is representative of the code for all the other classes.
> I am no expect on the hibernate implementation, but my suspicion of the cause is when hibernate substitutes a PersistentBag for the ArrayList in the merged object (associated with the session) it detects this as a change and hence triggers the update, unfortunately the data itself has not changed hence no update is necessary.
> FYI: If I change the initialization of the bags from "new ArrayList()" to "new PersistentBag()" the extra updates go away, however then it doesn't save real changes correctly.
> package com.mycompany.dal.transfer.impl;
> import org.apache.commons.lang.builder.EqualsBuilder;
> import org.apache.commons.lang.builder.HashCodeBuilder;
> import org.apache.commons.lang.builder.ToStringBuilder;
> import java.util.ArrayList;
> import java.util.Collections;
> import java.util.List;
> import com.mycompany.dal.transfer.interfaces.ADTO;
> import com.mycompany.dal.transfer.interfaces.BDTO;
> import com.mycompany.dal.transfer.interfaces.CDTO;
> import org.apache.commons.collections.Closure;
> import org.apache.commons.collections.CollectionUtils;
> public class BDTOImpl implements BDTO {
> public BDTOImpl () {
> }
> private Long bId;
>
> public Long getBId() {
> return bId;
> }
> public void setBId(Long bId) {
> this.bId = bId;
> }
> private Long concurrentVersion;
>
> public Long getConcurrentVersion() {
> return concurrentVersion;
> }
> public void setConcurrentVersion(Long concurrentVersion) {
> this.concurrentVersion = concurrentVersion;
> }
> // Package level protection so that overrides can access it.
> boolean deleting = false;
> private String name;
> /**
> * Returns the Name.
> *
> * @return String - The Name
> */
> public String getName() {
> return name;
> }
> /**
> * Set the Name.
> *
> * @param name String - The Name.
> */
> public void setName(String name) {
> this.name = name;
> }
> private ADTO a;
> /**
> * Returns the A.
> *
> * @return ADTO - The A.
> */
> public ADTO getA() {
> return a;
> }
>
> public ADTO getAInternal() {
> return a;
> }
> /**
> * Updates the A.
> *
> * @param a - ADTO The A.
> */
> public void setA(ADTO a) {
> if (this.a == a) {
> return;
> }
> if (this.a != null) {
> ((ADTOImpl) this.a).removeBInternal(this);
> }
> this.a = a;
> if (a != null) {
> ((ADTOImpl) a).addBInternal(this);
> }
> }
> public void setAInternal(ADTO a) {
> if (deleting) {
> return;
> }
> if (this.a != a &&
> this.a != null && a != null) {
> throw new IllegalStateException("BDTO cannot be a member of two A collections: " + toString());
> }
> this.a = a;
> }
> private List cs;
> private List csMutable;
> { setCsMutable(new ArrayList()); }
> public List getCsMutable() {
> return csMutable;
> }
> public void setCsMutable(List cs) {
> this.cs = Collections.unmodifiableList(cs);
> this.csMutable = cs;
> }
> public List getCs() {
> return cs;
> }
>
> public void addC(CDTO c) {
> csMutable.add(c);
> ((CDTOImpl) c).setBInternal(this);
> }
> public void addCInternal(CDTO c) {
> csMutable.add(c);
> }
>
> public void removeC(CDTO c) {
> csMutable.remove(c);
> ((CDTOImpl) c).setBInternal(null);
> }
> public void removeCInternal(CDTO c) {
> if (!deleting) {
> csMutable.remove(c);
> }
> }
> public void beforeDelete() {
> // Guard to prevent infinite loop.
> if (deleting) {
> return;
> }
>
> deleting = true;
> if (this.a != null) {
> ((ADTOImpl) this.a).removeBInternal(this);
> }
> CollectionUtils.forAllDo(new ArrayList(csMutable), new Closure() {
> public void execute(Object ob) {
> ((CDTOImpl) ob).beforeDelete();
> }
> });
> }
> public int hashCode() {
> return (new HashCodeBuilder(17,37)
> .append(getBId())
> ).toHashCode();
> }
> public boolean equals(Object o) {
> boolean equals = false;
> if (o != null && o instanceof BDTO) {
> BDTO other = (BDTO) o;
> return (new EqualsBuilder()
> .append(getBId(), other.getBId())
> ).isEquals();
> }
> return equals;
> }
>
> public String toString() {
> return new ToStringBuilder(this)
> .append("bId", getBId())
> .append("name", getName())
> .toString();
> }
> }
> ******************************
> *** Mapping Document ****
> ******************************
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
> <hibernate-mapping package="com.mycompany.dal.transfer.impl" auto-import="true">
> <class name="com.mycompany.dal.transfer.impl.BDTOImpl" table="b">
> <id name="BId" type="long">
> <column name="b_id" not-null="true"/>
> <generator class="native"/>
> </id>
> <version name="concurrentVersion" column="concurrent_version" type="long"/>
> <property name="Name" type="string">
> <column name="name" length="60" not-null="false"/>
> </property>
> <many-to-one name="AInternal" class="com.mycompany.dal.transfer.impl.ADTOImpl">
> <column name="a_id" not-null="true"/>
> </many-to-one>
> <bag name="CsMutable" cascade="all-delete-orphan" inverse="true">
> <key>
> <column name="b_id" not-null="true"/>
> </key>
> <one-to-many class="com.mycompany.dal.transfer.impl.CDTOImpl"/>
> </bag>
> </class>
> </hibernate-mapping>
> *************************
> *** Generated SQL ****
> *************************
> 05:35:39,887 INFO [STDOUT] Hibernate: select adtoimpl0_.a_id as a1_162_2_, adtoimpl0_.concurrent_version as concurrent2_162_2_, adtoimpl0_.name as name162_2_, bsmutable1_.a_id as a4_4_, bsmutable1_.b_id as b1_4_, bsmutable1_.b_id as b1_164_0_, bsmutable1_.concurrent_version as concurrent2_164_0_, bsmutable1_.name as name164_0_, bsmutable1_.a_id as a4_164_0_, csmutable2_.b_id as b4_5_, csmutable2_.c_id as c1_5_, csmutable2_.c_id as c1_165_1_, csmutable2_.concurrent_version as concurrent2_165_1_, csmutable2_.name as name165_1_, csmutable2_.b_id as b4_165_1_ from a adtoimpl0_ left outer join b bsmutable1_ on adtoimpl0_.a_id=bsmutable1_.a_id left outer join c csmutable2_ on bsmutable1_.b_id=csmutable2_.b_id where adtoimpl0_.a_id=?
> 05:35:39,992 INFO [STDOUT] Hibernate: select ddtoimpl0_.d_id as d1_168_0_, ddtoimpl0_.concurrent_version as concurrent2_168_0_, ddtoimpl0_.name as name168_0_, ddtoimpl0_.c_id as c4_168_0_ from d ddtoimpl0_ where ddtoimpl0_.d_id=?
> 05:35:40,007 INFO [STDOUT] Hibernate: select dsmutable0_.c_id as c4_1_, dsmutable0_.d_id as d1_1_, dsmutable0_.d_id as d1_168_0_, dsmutable0_.concurrent_version as concurrent2_168_0_, dsmutable0_.name as name168_0_, dsmutable0_.c_id as c4_168_0_ from d dsmutable0_ where dsmutable0_.c_id=?
> *** Start Extra Updates **
> 05:35:40,030 INFO [STDOUT] Hibernate: update b set concurrent_version=?, name=?, a_id=? where b_id=? and concurrent_version=?
> 05:35:40,038 INFO [STDOUT] Hibernate: update c set concurrent_version=?, name=?, b_id=? where c_id=? and concurrent_version=?
> 05:35:40,044 INFO [STDOUT] Hibernate: update a set concurrent_version=?, name=? where a_id=? and concurrent_version=?
> *** End Extra Updates **
> **************************
> *** Accessing code ****
> **************************
> DataAccessLayer dal = DataAccessLayerBuilder.getInstance();
>
> ADAO aDAO = dal.getADAO();
> BDAO bDAO = dal.getBDAO();
> CDAO cDAO = dal.getCDAO();
> DDAO dDAO = dal.getDDAO();
>
> ADTO a = aDAO.newA();
> a.setAId(new Long(1));
> a.setConcurrentVersion(new Long(0));
> a.setName("A");
>
> BDTO b = bDAO.newB();
> CDTO c = cDAO.newC();
> DDTO d = dDAO.newD();
> b.setBId(new Long(2));
> c.setCId(new Long(3));
> d.setDId(new Long(4));
> b.setConcurrentVersion(new Long(0));
> c.setConcurrentVersion(new Long(0));
> d.setConcurrentVersion(new Long(0));
> b.setName("B");
> c.setName("C");
> d.setName("D");
> b.setA(a);
> c.setB(b);
> d.setC(c);
>
> aDAO.mergeA(a);
--
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
18 years, 4 months
[Hibernate-JIRA] Updated: (HHH-1564) Possible bug with deleting versioned object (patch included)
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1564?page=all ]
Steve Ebersole updated HHH-1564:
--------------------------------
Fix Version: 3.2.1
Assign To: Steve Ebersole
> Possible bug with deleting versioned object (patch included)
> ------------------------------------------------------------
>
> Key: HHH-1564
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1564
> Project: Hibernate3
> Type: Bug
> Components: core
> Versions: 3.1.2
> Environment: 3.1rc2
> Reporter: N Clayton
> Assignee: Steve Ebersole
> Fix For: 3.2.1
> Attachments: onetomanydelete_test.tar.gz
>
>
> We're seeing an odd problem when trying to delete a row. The code that does this simply creates a new object, commits it, starts a new session, finds the object, deletes it. It dies with a constraint violation on an audit table, because hibernate is issuing an unnecessary update operation (and not incrementing the version either). Further debugging shows that Hibernate thinks that three properties on the object are 'modified'. These three are collections. One is the points collection, one owners and the other is systems. Hibernate seems to think that they are 'different' because null != an empty collection. So, it thinks it needs to update the object. However; later on - it doesn't increment the version number - because it knows the object is to be deleted. Thus - a problem.
> A complete description is here:
> http://forum.hibernate.org/viewtopic.php?t=950225&highlight=collectiontyp...
> This appears to be fixed if we change CollectionType.isDirty() to be:
> public boolean isDirty(Object old, Object current, boolean[] checkable, SessionImplementor session)
> throws HibernateException {
> if(checkable.length == 0) {
> // Assume not checkable
> return false;
> }
> return isDirty(old, current, session);
> }
--
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
18 years, 4 months
[Hibernate-JIRA] Updated: (HHH-1668) PersistentSet write methods mark collection as dirty even if entry is not written
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1668?page=all ]
Steve Ebersole updated HHH-1668:
--------------------------------
Summary: PersistentSet write methods mark collection as dirty even if entry is not written (was: PersistentSet.add() marks as dirty even if Set is not updated)
Fix Version: 3.2.1
Assign To: Steve Ebersole
> PersistentSet write methods mark collection as dirty even if entry is not written
> ---------------------------------------------------------------------------------
>
> Key: HHH-1668
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1668
> Project: Hibernate3
> Type: Bug
> Components: core
> Versions: 3.1.3
> Reporter: Koda Janh
> Assignee: Steve Ebersole
> Fix For: 3.2.1
> Attachments: PersistentSet.patch
>
> Original Estimate: 5 minutes
> Remaining: 5 minutes
>
> PersistentSet gets marked as dirty even if it hasn't changed. This has negative implications for concurrency because the optimistic-lock version is incremented and StaleObjectStateException is thrown even if the underlying data remains unchanged.
> I stepped through the code and narrowed down the problem to a bug in PersistentSet.add(). A simple fix is to replace:
> if (exists==null) {
> write();
> return set.add(value);
> }
> by:
> if (exists==null) {
> boolean result = set.add(value);
> if (result) {
> write();
> }
> return result;
> }
> I verified that this fixed the problem on my end. The old code was always marking the Set as dirty whereas the new code only does so if it actually has been modified. Please commit this patch.
--
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
18 years, 4 months
[Hibernate-JIRA] Resolved: (ANN-382) Id involving many to one may fail depending on the entity process ordering
by Emmanuel Bernard (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-382?page=all ]
Emmanuel Bernard resolved ANN-382:
----------------------------------
Resolution: Fixed
> Id involving many to one may fail depending on the entity process ordering
> --------------------------------------------------------------------------
>
> Key: ANN-382
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-382
> Project: Hibernate Annotations
> Type: Bug
> Environment: Hibernate's annotations packaged in JBoss EJB 3.0 RC8- FD
> Microsoft SQL Server 2000
> Reporter: Pierre Fourès
> Assignee: Emmanuel Bernard
> Fix For: 3.2.0.cr2
> Attachments: BugEJB3.zip
>
>
> As described in hibernate forum (http://forum.hibernate.org/viewtopic.php?t=960763) and discussed with Emmanuel, I encounter a strange behaviour with annotations depending of my package's names.
> Supposing hibernate load classes by package alphabetical order; if it get the "parent" class first all works fine, if it get the "child" class first, it raise an exception !
> Here is a subset of my classes, cleaned of getters, setters and all unrelated things, then followed by the exception stack :
> ///////////////////////////////////////////////
> package fr.ifis.entity.field.card;
> import java.io.Serializable;
> import javax.persistence.Embeddable;
> import javax.persistence.Entity;
> import javax.persistence.Id;
> import javax.persistence.ManyToOne;
> import fr.ifis.entity.project.Card;
> @Entity
> public class CardField {
> @Id
> private PrimaryKey primaryKey = new PrimaryKey();
>
> // cardtmp is a trick used in order to wait for http://opensource.atlassian.com/projects/hibernate/browse/ANN-381 resolution
> @ManyToOne
> private Card cardtmp;
> @Embeddable
> private class PrimaryKey implements Serializable {
>
> @ManyToOne(optional = false)
> private Card card;
>
> @ManyToOne(optional = false)
> private CardKey key;
> }
> }
> ///////////////////////////////////////////////
> package fr.ifis.entity.field.card;
> import javax.persistence.Entity;
> import javax.persistence.GeneratedValue;
> import javax.persistence.Id;
> @Entity
> public class CardKey {
> @Id
> @GeneratedValue
> private int id;
> }
> ///////////////////////////////////////////////
> package fr.ifis.entity.project;
> import java.io.Serializable;
> import java.util.Set;
> import javax.persistence.CascadeType;
> import javax.persistence.Embeddable;
> import javax.persistence.Entity;
> import javax.persistence.FetchType;
> import javax.persistence.Id;
> import javax.persistence.ManyToOne;
> import javax.persistence.OneToMany;
> import fr.ifis.entity.field.card.CardField;
> @Entity
> public class Card {
> @Id
> private CardPrimaryKey primaryKey = new CardPrimaryKey();
>
> @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER, mappedBy="cardtmp") //
> private Set<CardField> fields;
>
> @Embeddable
> private class CardPrimaryKey implements Serializable {
>
> @ManyToOne(optional = false)
> private Project project;
>
> //An other @ManyToOne is also present in the real model
> //The problem still occurs even when i remove this relation, it was no use to kept it for describe the problem
> }
> }
> ///////////////////////////////////////////////
> package fr.ifis.entity.project;
> import javax.persistence.Entity;
> import javax.persistence.GeneratedValue;
> import javax.persistence.Id;
> @Entity
> public class Project {
> @Id
> @GeneratedValue
> private int id;
> }
> ///////////////////////////////////////////////
> [java] ERROR 29-06 19:42:18,272 (AbstractController.java:incrementState:350) -Error installing to Start: name=persistence.units:unitName=Refonte state=Create
> [java] org.hibernate.MappingException: Foreign key (FK6771BFAA1845E8B:CardField [])) must have same number of columns as the referenced primary key (Card [project_id])
> [java] at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:90)
> [java] at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:73)
> [java] at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1182)
> [java] at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1089)
> [java] at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:302)
> [java] at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1034)
> [java] at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1015)
> [java] at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
> [java] at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:751)
> [java] at org.hibernate.ejb.Ejb3Configuration.createContainerEntityManagerFactory(Ejb3Configuration.java:350)
> [java] at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:119)
> [java] at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:264)
> [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> [java] at java.lang.reflect.Method.invoke(Method.java:585)
> [java] at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:55)
> [java] at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:107)
> [java] at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
> [java] at org.jboss.kernel.plugins.dependency.KernelControllerContextActions.dispatchJoinPoint(KernelControllerContextActions.java:100)
> [java] at org.jboss.kernel.plugins.dependency.KernelControllerContextActions$LifecycleAction.installAction(KernelControllerContextActions.java:582)
> [java] at org.jboss.kernel.plugins.dependency.KernelControllerContextActions$KernelControllerContextAction.install(KernelControllerContextActions.java:175)
> [java] at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
> [java] at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:226)
> [java] at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:593)
> [java] at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:346)
> [java] at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:438)
> [java] at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:379)
> [java] at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:225)
> [java] at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:151)
> [java] at org.jboss.kernel.plugins.dependency.AbstractKernelController.install(AbstractKernelController.java:79)
> [java] at org.jboss.kernel.plugins.dependency.AbstractKernelController.install(AbstractKernelController.java:73)
> [java] at org.jboss.ejb3.MCKernelAbstraction.install(MCKernelAbstraction.java:91)
> [java] at org.jboss.ejb3.Ejb3Deployment.startPersistenceUnits(Ejb3Deployment.java:626)
> [java] at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:475)
> [java] at org.jboss.ejb3.embedded.EJB3StandaloneDeployer.start(EJB3StandaloneDeployer.java:460)
> [java] at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.scanClasspath(EJB3StandaloneBootstrap.java:291)
> [java] at fr.ifis.Main.main(Unknown Source)
> ///////////////////////////////////////////////
> Indeed, depending on the package names I get or not an excpetion !
> It doesn't work with the package fr.ifis.entity.project but if I rename the package in fr.ifis.entity.aproject and then move it "before" the field.card package, all works fine.
> In order to facilitate the identification of the problem, I also include as attachement the eclipse project of this problem repport.
> In order to keep reasonable the size of the attachement, I did not included the libraries nor the configuration files for launch ejb3-embedded. Thoses files are issued from the project simple-deployment included in JBoss EJB 3.0 RC8-FD. The only change i've done was to specify in embedded-jboss-beans.xml the properties of my database.
> Regards,
> Pierre.
--
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
18 years, 4 months
[Hibernate-JIRA] Updated: (HHH-1668) PersistentSet.add() marks as dirty even if Set is not updated
by Koda Janh (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1668?page=all ]
Koda Janh updated HHH-1668:
---------------------------
Attachment: PersistentSet.patch
Here is a patch against HEAD branch. Please incorporate it into the next release.
> PersistentSet.add() marks as dirty even if Set is not updated
> -------------------------------------------------------------
>
> Key: HHH-1668
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1668
> Project: Hibernate3
> Type: Bug
> Components: core
> Versions: 3.1.3
> Reporter: Koda Janh
> Attachments: PersistentSet.patch
>
> Original Estimate: 5 minutes
> Remaining: 5 minutes
>
> PersistentSet gets marked as dirty even if it hasn't changed. This has negative implications for concurrency because the optimistic-lock version is incremented and StaleObjectStateException is thrown even if the underlying data remains unchanged.
> I stepped through the code and narrowed down the problem to a bug in PersistentSet.add(). A simple fix is to replace:
> if (exists==null) {
> write();
> return set.add(value);
> }
> by:
> if (exists==null) {
> boolean result = set.add(value);
> if (result) {
> write();
> }
> return result;
> }
> I verified that this fixed the problem on my end. The old code was always marking the Set as dirty whereas the new code only does so if it actually has been modified. Please commit this patch.
--
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
18 years, 4 months
[Hibernate-JIRA] Commented: (HHH-1901) Filtering on superclass property problem
by Juan Ignacio Cidre (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1901?page=c... ]
Juan Ignacio Cidre commented on HHH-1901:
-----------------------------------------
Here I have a minimum test case:
Class files:
package test;
import java.util.Set;
public class MyBean {
private Long id;
private String name;
private Set<MySubclass> subclasses;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<MySubclass> getSubclasses() {
return subclasses;
}
public void setSubclasses(Set<MySubclass> subclasses) {
this.subclasses = subclasses;
}
}
package test;
public class MySuperclass {
private Long id;
private String name;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package test;
public class MySubclass extends MySuperclass {
private String anotherProperty;
public String getAnotherProperty() {
return anotherProperty;
}
public void setAnotherProperty(String anotherProperty) {
this.anotherProperty = anotherProperty;
}
}
Mapping files:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="test.MyBean"
table="mybean">
<id name="id" type="long" unsaved-value="null" >
<column name="ID" sql-type="NUMBER(4)" not-null="true"/>
</id>
<property name="name" />
<set name="subclasses" >
<key column="myBeanId"/>
<one-to-many class="test.MySubclass"/>
<filter name="nameFilter"/>
</set>
</class>
<filter-def name="nameFilter" condition="name = 'TheOne'"/>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="test.MySuperclass" table="mysuperclass">
<id name="id" type="long" unsaved-value="null" >
<column name="ID" sql-type="NUMBER(4)" not-null="true"/>
</id>
<property name="name"/>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<joined-subclass name="test.MySubclass"
table="mySubclass"
extends="test.MySuperclass">
<key column="id" />
<property name="anotherProperty"/>
</joined-subclass>
</hibernate-mapping>
DB scripts (for oracle):
CREATE TABLE mybean(
id NUMBER(10) NOT NULL,
name VARCHAR2(128) NOT NULL
);
ALTER TABLE mybean
ADD CONSTRAINT mybeanid
PRIMARY KEY(id);
CREATE TABLE mysuperclass(
id NUMBER(10) NOT NULL,
name VARCHAR2(10) NOT NULL
);
ALTER TABLE mysuperclass
ADD CONSTRAINT mysuperclassid
PRIMARY KEY(id);
CREATE TABLE mysubclass(
id NUMBER(10) NOT NULL,
anotherProperty VARCHAR2(10) NOT NULL,
myBeanId NUMBER(10) NOT NULL
);
ALTER TABLE mysubclass
ADD CONSTRAINT mysubclassid
PRIMARY KEY(id);
ALTER TABLE mysubclass
ADD CONSTRAINT mysubclassidfk
FOREIGN KEY (id) REFERENCES mysuperclass(id);
ALTER TABLE mysubclass
ADD CONSTRAINT mysubclassbeanidfk
FOREIGN KEY (myBeanId) REFERENCES mybean(id);
INSERT INTO mybean VALUES(1, 'myBean');
INSERT INTO mysuperclass VALUES(1, 'sclass 1');
INSERT INTO mysubclass VALUES(1, 'property 1', 1);
INSERT INTO mysuperclass VALUES(2, 'sclass 2');
INSERT INTO mysubclass VALUES(2, 'property 2', 1);
Test code:
//First the session factory must be obtained
//Open session
Session session = factory.openSession();
//enables the filter
session.enableFilter("nameFilter");
MyBean myBean = (MyBean)session.load(MyBean.class.getName(), new Long(1));
//Here the exception occurs
myBean.getSubclasses().size();
When the set is initialized the SQL exception is thrown, here is the malformed query:
select subclasses0_.myBeanId as myBeanId1_,
subclasses0_.id as id1_,
subclasses0_.id as ID136_0_,
subclasses0_1_.name as name136_0_,
subclasses0_.anotherProperty as anotherP2_137_0_
from mySubclass subclasses0_
inner join mysuperclass subclasses0_1_ on subclasses0_.id=subclasses0_1_.ID
where subclasses0_.name = 'TheOne' and subclasses0_.myBeanId=?
The problem here is in the first condition of the where clause, as you can see the column name does not exist in mySubclass table, but in mySuperclass table.
Hope this is clear enough, otherwise let me know.
> Filtering on superclass property problem
> ----------------------------------------
>
> Key: HHH-1901
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1901
> Project: Hibernate3
> Type: Bug
> Versions: 3.1.3
> Environment: Hibernate 3.1.3 on Oracle 9i
> Reporter: Juan Ignacio Cidre
>
>
> I have three classes Order, Advertisements and Creatives.
> Advertisements is subclass of Creatives
> Order has a one-to-many to Advertisements
> That one-to-many has a filter. The condition has to do with a property of Creative, the Advertisements superclass.
> This is the Order to Advertisements mapping with a filter on deletionStatusId that is a field of Creative.
> <set name="ads" inverse="true" lazy="true">
> <key column="orderId"/>
> <one-to-many class="com.inceptor.domain.msn.Advertisement"/>
> <filter name="deletionStatusFilter" condition="deletionStatusId = 0"/>
> </set>
> This is the Creative mapping with the deletionStatusId, which is mapped as a component. It is a Enum in Java.
> <component name="deletionStatus"
> class="com.inceptor.domain.core.DeletionStatusType">
> <property name="number" column="deletionStatusId" />
> </component>
> I would expected an sql that appends a where condition like [superclass (Creative) table alias].deletionStatusId instead I received [subclass (Advertisements) table alias].deletionStatusId
> This generates a DB error.
> Follows the generated query
> Note ads0_ instead of ads0_1_
> select ads0_.orderId as orderId1_, ads0_.id as id1_, ads0_.id as ID324_0_, ads0_1_.version as version324_0_, ads0_1_.searchEngineAccountId as searchEn3_324_0_, ads0_1_.creationTime as creation4_324_0_, ads0_1_.creatorId as creatorId324_0_, ads0_1_.modificationTime as modifica6_324_0_, ads0_1_.synchTime as synchTime324_0_, ads0_1_.modifierId as modifierId324_0_, ads0_1_.deletionStatusId as deletion9_324_0_, ads0_1_.deleterId as deleterId324_0_, ads0_1_.pushError as pushError324_0_, ads0_.seId as seId418_0_, ads0_.title as title418_0_, ads0_.description as descript4_418_0_, ads0_.displayURL as displayURL418_0_, ads0_.destinationURL as destinat6_418_0_, ads0_.originalDestinationURL as original7_418_0_, ads0_.orderId as orderId418_0_ from MSN_Advertisements ads0_ inner join GTK_Creatives ads0_1_ on ads0_.id=ads0_1_.ID where ads0_.deletionStatusId = 0 and ads0_.orderId=?
--
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
18 years, 4 months
[Hibernate-JIRA] Created: (HHH-2040) problem with MySQL 5.0 in a standalone application; unable to insert records in a certain case
by Timothy Heider (JIRA)
problem with MySQL 5.0 in a standalone application; unable to insert records in a certain case
----------------------------------------------------------------------------------------------
Key: HHH-2040
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2040
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.1.2
Environment: Windows XP Home Edition; Java 1.5.0_08 (JDK); MySQL server 5.0; MySQL Connector/J 3.0 or 3.1 (doesn't matter)
Reporter: Timothy Heider
Attachments: Practice.hbm.xml, hibernate-configuration-3.0.dtd, hibernate-mapping-3.0.dtd
Hello,
I have found a workaround for this, but I wanted to report my experience.
I am starting out with Hibernate and have spent the past few days building my "hello world" ap.
I finally got SchemaExport working and my configuration set up. My database is all set up, etc.
When I do this, it works:
public static void main(String[] args) {
Configuration cfg = new Configuration();
SessionFactory factory = cfg.configure("primeschedule/hibernate/hibernate.cfg.xml").buildSessionFactory();
for(int i=0;i < 5;i++) {
Session session = factory.openSession();
session.beginTransaction();
Practice p = new Practice();
p.setName("tim-" + Integer.toString(i));
session.save(p);
session.getTransaction().commit();
session.close();
}
factory.close();
}
but when I do this it does not:
public static void main(String[] args) {
Configuration cfg = new Configuration();
SessionFactory factory = cfg.configure("primeschedule/hibernate/hibernate.cfg.xml").buildSessionFactory();
for(int i=0;i < 5;i++) {
Session session = factory.openSession();
session.beginTransaction();
Practice p = new Practice();
p.setName("tim-" + Integer.toString(i));
session.save(p);
session.flush();
session.close();
}
factory.close();
}
If I run the second test case in JDB it would actually output junk to the screen and crash! When running test case 2 in the standard java interpreter it outputs the INSERT statement, but the records do not post to the database. Weird.
My workaround is to not use FLUSH but instead use getTransaction().commit(). The book "Hibernate Quickly" suggests using the flush command at the end of the session.
Thanks for your attention,
Tim
--
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
18 years, 4 months