[Hibernate-JIRA] Resolved: (ANN-406) @Embedded can not be used with Generics
by Emmanuel Bernard (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-406?page=all ]
Emmanuel Bernard resolved ANN-406:
----------------------------------
Resolution: Rejected
no test case provided
> @Embedded can not be used with Generics
> ---------------------------------------
>
> Key: ANN-406
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-406
> Project: Hibernate Annotations
> Type: Bug
> Versions: 3.2.0.cr1
> Environment: Hibernate 3.1.2 Oracle 10g
> Reporter: Michael Kantarovich
> Priority: Critical
>
>
> The following:
> @Embedded
> MyClass<MyGeneric> getMyClass(){
> return myClass;
> }
> will result and exception:
> java.lang.IllegalStateException: Property myClass has an unbound type and no explicit target entity.
> at org.hibernate.cfg.AnnotationBinder.addElementsOfAClass(AnnotationBinder.java:938)
> at org.hibernate.cfg.AnnotationBinder.getElementsToProcess(AnnotationBinder.java:788)
> at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:614)
> at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:353)
> at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:265)
> at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1034)
> at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:56)
> at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:226)
> at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45)
> at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:160)
> 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)
> 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.ant.execution.AntMain2.main(AntMain2.java:17)
--
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: (ANN-7) Document usage of @IndexColumn in one-to-many with indexed collection
by Emmanuel Bernard (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-7?page=all ]
Emmanuel Bernard updated ANN-7:
-------------------------------
Component: documentation
(was: binder)
Fix Version: 3.2.0
> Document usage of @IndexColumn in one-to-many with indexed collection
> ---------------------------------------------------------------------
>
> Key: ANN-7
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-7
> Project: Hibernate Annotations
> Type: Improvement
> Components: documentation
> Versions: 3.2.0.cr1
> Environment: Hibernate 3.0.5, Hibernate Annotations 3.0 beta2 preview, HSQL DB
> Reporter: Ronald Wildenberg
> Assignee: Emmanuel Bernard
> Priority: Minor
> Fix For: 3.2.0
>
>
> I have a mapping for a List that does not result in the index column of the database table to be filled.
> @Entity
> public class A {
> @OneToMany(mappedBy = "a")
> @Cascade(value = CascadeType.SAVE_UPDATE)
> @IndexColumn(name = "index", base = 0)
> public List<B> getBs() {
> return bs;
> }
> public void setBs(List<B> bs) {
> this.bs = bs;
> }
> }
> @Entity
> public class B {
>
> @ManyToOne(optional = false)
> @JoinColumn(name = "a_id")
> public A getA() {
> return a;
> }
> public void setA(A a) {
> this.a = a;
> }
> }
> Using this mapping, the 'index' column for table B is never filled if I add B objects to A and save them.
> The weird thing is, if I change the mapping for getBs to the following:
> @OneToMany
> @Cascade(value = CascadeType.SAVE_UPDATE)
> @IndexColumn(name = "index", base = 0)
> an association table is created with columns a_id, b_id, index. The only change I made is removing the mappedBy attribute. This association table is not necessary, since an index column can be added to table B.
--
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: (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 updated ANN-382:
---------------------------------
Summary: Id involving many to one may fail depending on the entity process ordering (was: Exception raising : Strange behaviour depending on package names)
> 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
> 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: (ANN-361) HA takes metadata from IdClass rather than the entity itself
by Emmanuel Bernard (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-361?page=all ]
Emmanuel Bernard updated ANN-361:
---------------------------------
Summary: HA takes metadata from IdClass rather than the entity itself (was: @Column(name="xxxx") does not work when composit key is used)
> HA takes metadata from IdClass rather than the entity itself
> ------------------------------------------------------------
>
> Key: ANN-361
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-361
> Project: Hibernate Annotations
> Type: Bug
> Versions: 3.2.0.cr1
> Reporter: Thomas Risberg
>
>
> When using a composit key and specifying name of id column - the specified name is ignored and a column with the name of the field is generated.
> This:
> -------------
> import java.io.Serializable;
> public class ProductItemPK implements Serializable {
> private Long productId;
> private Long itemId;
> }
> -------------
> import javax.persistence.*;
> @Entity
> @IdClass(value=ProductItemPK.class)
> public class ProductItem {
> @Id
> @Column(name="product_id")
> private Long productId;
> @Id
> @Column(name="item_id")
> private Long itemId;
> private String name;
> }
> -------------
> results in:
> create table ProductItem (
> productId number(19,0) not null,
> itemId number(19,0) not null,
> name varchar2(255 char),
> primary key (productId, itemId)
> )
--
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-2028) IncrementGenerator broken for tables with blanks in their names after TODO-173
by Erik Bertelsen (JIRA)
IncrementGenerator broken for tables with blanks in their names after TODO-173
------------------------------------------------------------------------------
Key: HHH-2028
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2028
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.0.cr3
Environment: Hibernate since ca. 3.1, verified at CVS of 24 Aug 2006
Reporter: Erik Bertelsen
The following change to IncrementGenerator.java
revision 1.11
date: 2005/04/26 06:37:53; author: oneovthafew; state: Exp; lines: +24 -5
TODO-173, increment for union-subclass
SQL logging from id generators
----------------------------
seems to have broken this generator when used on tables with blanks in their names.
This update tries to allow access to a comma-separated list of tables to identify the currently max-value of an id column.
I have a with the following mapping (in extract):
<hibernate-mapping>
<class name="dk.statsbiblioteket.navision.integration.Transaction" table="`REGNSKAB$SB Transaktioner`" dynamic-update="true">
<id name="lbNummer">
<column name="`Løbenr`" />
<generator class="increment" />
</id>
<discriminator column="`Trans type`" />
....
When trying to save a new entry of this mapped class, I get the following failure:
2006-03-19 10:52:09,828 [main] DEBUG org.hibernate.id.IncrementGenerator - fetching initial value: select max(ids_.[Løbenr]) from ( select [Løbenr] from [Statsbiblioteket$SB union select [Løbenr] from Transaktioner] ) ids_
Hibernate: select max(ids_.[Løbenr]) from ( select [Løbenr] from [Statsbiblioteket$SB union select [Løbenr] from Transaktioner] ) ids_
2006-03-19 10:52:09,852 [main] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 156, SQLState: S1000
2006-03-19 10:52:09,852 [main] ERROR org.hibernate.util.JDBCExceptionReporter - Incorrect syntax near the keyword 'from'.
Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not fetch initial value for increment generator
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:107)
at org.hibernate.id.IncrementGenerator.generate(IncrementGenerator.java:44)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:90)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:534)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:522)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:518)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
at $Proxy0.save(Unknown Source)
at dk.statsbiblioteket.navision.integration.UpdateItemPriceTransactionDAO.save(UpdateItemPriceTransactionDAO.java:45)
at dk.statsbiblioteket.videnstafetten.TidsskriftAar.requestNavisionItemPriceUpdate(TidsskriftAar.java:1188)
at dk.statsbiblioteket.videnstafetten.TidsskriftAar.verifyNavisionItemContents(TidsskriftAar.java:1132)
at dk.statsbiblioteket.videnstafetten.TidsskriftAar.synchronizeNavisionItem(TidsskriftAar.java:1077)
at synchronizeNavisionVare.sync(synchronizeNavisionVare.java:95)
at synchronizeNavisionVare.main(synchronizeNavisionVare.java:31)
Caused by: java.sql.SQLException: Incorrect syntax near the keyword 'from'.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:365)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2781)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2224)
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:628)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:418)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:693)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at org.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:85)
... 22 more
Note that the table name contains a blank and that this causes the configure method of the generator to think that it must access two tables.
The following patch seems to fix the problem, at least for me:
svn diff
Index: IncrementGenerator.java
===================================================================
--- IncrementGenerator.java (revision 9658)
+++ IncrementGenerator.java (working copy)
@@ -51,7 +51,7 @@
String tableList = params.getProperty("tables");
if (tableList==null) tableList = params.getProperty(PersistentIdentifierGenerator.TABLES);
- String[] tables = StringHelper.split(", ", tableList);
+ String[] tables = StringHelper.split(",", tableList);
String column = params.getProperty("column");
if (column==null) column = params.getProperty(PersistentIdentifierGenerator.PK);
String schema = params.getProperty(PersistentIdentifierGenerator.SCHEMA);
What causes the problem is that StringHelper.split will tokenize the table name based on any comma and any blank. My change tells it to only split on commas (as the documentation indicates).
If you want to allow blanks after the table name separating commas, you probably need to parse the list of table names more carefully to handle quoted names with blanks in them. A slightly different solution that will probably work in most cases would be to split on the regex ",\s*", i.e. allowing any number of blanks after a comma.
- Erik
--
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