[Hibernate-JIRA] Commented: (ANN-381) Make possible to specify an @EmbeddedId's field in a @OneToMany's mappedBy property
by Brice Laurencin (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-381?page=co... ]
Brice Laurencin commented on ANN-381:
-------------------------------------
more details:
in fact, the previous code wasn't accurate.
Pool declares poolAdministrators as follows:
@OneToMany(fetch = FetchType.LAZY, mappedBy = "id.pool")
@JoinTable(name="POOL_ADMIN")
private Set<PoolAdministrator> poolAdministrators = new HashSet<PoolAdministrator>(
0);
Now, if I remove the JoinTable, it tries to work on
POOL_ADMIN_USER where POOL_PK_POOL=?
where it should be ADMIN_USER where PK_POOL=?
> Make possible to specify an @EmbeddedId's field in a @OneToMany's mappedBy property
> -----------------------------------------------------------------------------------
>
> Key: ANN-381
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-381
> Project: Hibernate Annotations
> Issue Type: Improvement
> Components: binder
> Environment: Hibernate's annotations packaged in JBoss EJB 3.0 RC8- FD
> Microsoft SQL Server 2000
> Reporter: Pierre Fourès
> Fix For: 3.2.0.cr2
>
>
> As described in hibernate forum (http://forum.hibernate.org/viewtopic.php?t=960763) and discussed with Emmanuel, it would be very nice to be able to specify in an @OneToMany's mappedBy property the field of an @EmbeddedId.
> For example, i would like to be able run this example :
> @Entity
> public class Card {
> @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER, mappedBy="primaryKey.card")
> private Set<CardField> fields;
> }
> @Entity
> public class CardField implements Field {
> @EmbeddedId
> private PrimaryKey primaryKey = new PrimaryKey();
>
> @Embeddable
> class PrimaryKey implements Serializable {
> @ManyToOne(optional = false)
> private Card card;
>
> @ManyToOne(optional = false)
> private Key key;
> }
> }
> @Entity
> public class Key {}
--
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
14 years, 11 months
[Hibernate-JIRA] Commented: (ANN-381) Make possible to specify an @EmbeddedId's field in a @OneToMany's mappedBy property
by Brice Laurencin (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-381?page=co... ]
Brice Laurencin commented on ANN-381:
-------------------------------------
I can't get this to work.
I get an NPE:
java.lang.NullPointerException
at org.hibernate.cfg.annotations.CollectionBinder.bindManytoManyInverseFk(CollectionBinder.java:1370)
at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1298)
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:602)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:543)
here is the mapping:
@Entity
public class Pool {
@Id
@Column(name = "PK_POOL", unique = true, nullable = false, length = 8)
private String id;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "id.admin")
private Set<PoolAdministrator> adminPools = new HashSet<PoolAdministrator>(0);
}
@Entity
@Table(name = "ADMIN_POOL")
public class PoolAdministrator {
@EmbeddedId
private PoolAdministratorId id;
}
@Embeddable
public class PoolAdministratorId {
@ManyToOne(fetch = FetchType.EAGER,optional=false)
@JoinColumn(name = "FK_POOL")
private Pool pool;
}
The exception ocures here:
property.getPersistentClass().getIdentifier(). Property.getPersistentClass() gives null, where it might give Pool, am I wrong?
> Make possible to specify an @EmbeddedId's field in a @OneToMany's mappedBy property
> -----------------------------------------------------------------------------------
>
> Key: ANN-381
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-381
> Project: Hibernate Annotations
> Issue Type: Improvement
> Components: binder
> Environment: Hibernate's annotations packaged in JBoss EJB 3.0 RC8- FD
> Microsoft SQL Server 2000
> Reporter: Pierre Fourès
> Fix For: 3.2.0.cr2
>
>
> As described in hibernate forum (http://forum.hibernate.org/viewtopic.php?t=960763) and discussed with Emmanuel, it would be very nice to be able to specify in an @OneToMany's mappedBy property the field of an @EmbeddedId.
> For example, i would like to be able run this example :
> @Entity
> public class Card {
> @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER, mappedBy="primaryKey.card")
> private Set<CardField> fields;
> }
> @Entity
> public class CardField implements Field {
> @EmbeddedId
> private PrimaryKey primaryKey = new PrimaryKey();
>
> @Embeddable
> class PrimaryKey implements Serializable {
> @ManyToOne(optional = false)
> private Card card;
>
> @ManyToOne(optional = false)
> private Key key;
> }
> }
> @Entity
> public class Key {}
--
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
14 years, 11 months
[Hibernate-JIRA] Commented: (HHH-1961) Schema validation fails with floating point column in Oracle 10g
by Daniel Thommes (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1961?page=c... ]
Daniel Thommes commented on HHH-1961:
-------------------------------------
I'm working with Hibernate 3.1rc2 and had the same problem. In this version I found a workaround that might help in later versions also: In the column metadata of my Hibernate mapping I added the information
sql-type="number"
Please be sure to make the type string lowercase (!). The issue results from the following code found in
org.hibernate.mapping.Table.validateColumns(Dialect dialect, Mapping mapping, TableMetadata tableInfo)
final boolean typesMatch = col.getSqlType(dialect, mapping).startsWith( columnInfo.getTypeName().toLowerCase() ) || columnInfo.getTypeCode() == col.getSqlTypeCode(mapping);
-> This line converts the type extracted from the JDBC column metadata to lowercase which will result in "NUMBER" being marked as type mismatch.
> Schema validation fails with floating point column in Oracle 10g
> ----------------------------------------------------------------
>
> Key: HHH-1961
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1961
> Project: Hibernate Core
> Issue Type: Bug
> Affects Versions: 3.2.0.cr2
> Environment: 3.2 CR 2, Oracle 10g express edition release 2, Windows XP service pack 2, JDK 1.5.0_06
> Reporter: Daniel Dyer
>
> I have a table (created automatically by Hibernate) for mapping a double field. The table creation from Ant works fine but when starting up JBoss with the hibernate.hbm2ddl.auto property set to validate, I get the following exception:
> Caused by: org.hibernate.HibernateException: Wrong column type: percentage, expected: double precision
> at org.hibernate.mapping.Table.validateColumns(Table.java:219)
> at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:965)
> at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
> at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:296)
> at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
> at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:414)
> at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:575)
> at org.hibernate.ejb.Ejb3Configuration.createContainerEntityManagerFactory(Ejb3Configuration.java:245)
> at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:108)
> at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:260)
> ... 127 more
> Doing a "desc" on the table reveals that the column is of type FLOAT with a length of 22.
> I think this may be related to issue HHH-1566 or HHH-1008.
--
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
14 years, 11 months