[Hibernate-JIRA] Created: (ANN-583) generator class with <composite-id>
by sai sirisha (JIRA)
generator class with <composite-id>
-----------------------------------
Key: ANN-583
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-583
Project: Hibernate Annotations
Type: New Feature
Versions: 3.1beta9
Environment: Version 3.1, database is oracle
Reporter: sai sirisha
Priority: Critical
Attachments: DsEpsdDietProfileHdr.hbm.xml
We have a requirement in our project that along with composite keys we have to put one attribute as autoincrement or sequence.How can we do this.
e.g
<class name="xyz">
<composite-id name="id" class="com.iba.ehis.dobj.DsEpsdDietProfileHdrId" >
<key-many-to-one name="prEncounter" class="com.iba.ehis.dobj.PrEncounter">
<column name="OPERATING_FACILITY_ID" length="6" />
<column name="ENCOUNTER_ID" precision="12" scale="0" />
</key-many-to-one>
<key-property name="profileSl" type="java.lang.Long">
<column name="PROFILE_SL" precision="2" scale="0" />
</key-property>
</composite-id>
</class>
In the above code i want key-property "profileSl" as autoincriment field.How can i achive this.
--
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, 6 months
[Hibernate-JIRA] Created: (HHH-2491) criteria failing with custom user type
by Luca Dall'Olio (JIRA)
criteria failing with custom user type
--------------------------------------
Key: HHH-2491
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2491
Project: Hibernate3
Type: Bug
Environment: hibernate 3.2.2-GA hsqldb 8.0.1
Reporter: Luca Dall'Olio
When executing a criteria query with a custom <id> type, hibernate ignores the custom type trying to set a primitive type instead; whereas load() works succesfully :
Below is some code that helps reproducing this problem :
Example of a custom Identifier Generator :
package sample;
...
public class CustomIdentifierGenerator implements IdentifierGenerator, PostInsertIdentifierGenerator, Configurable {
private static IdentityGenerator hibernateGeneratorDelegate = null;
public void configure(Type type, Properties props, Dialect dialect)
throws MappingException {
hibernateGeneratorDelegate = IdentifierGeneratorFactory.create(
"sequence", new LongType(), props, dialect);
if (hibernateGeneratorDelegate instanceof Configurable) {
((Configurable) hibernateGeneratorDelegate).configure(
new LongType(), props, dialect);
}
}
public Serializable generate(SessionImplementor session, Object object)
throws HibernateException {
return hibernateGeneratorDelegate.generate(session, object);
}
public InsertGeneratedIdentifierDelegate getInsertGeneratedIdentifierDelegate(
PostInsertIdentityPersister persister, Dialect dialect,
boolean isUseGet) throws HibernateException {
return hibernateGeneratorDelegate.getInsertGeneratedIdentifierDelegate(persister, dialect, isUseGet);
}
}
Mapping snippet :
<class
name="sample.SimpleEntity"
table="TB_SMP_SIMPLE">
<id name="entityPK" type="sample.LongEntityPK" column="SMP_ID">
<generator class="sample.CustomIdentifierGenerator" />
</id>
</class>
Entity class :
package sample;
....
public class SimpleEntity {
Query code :
SimpleEntity de = new SimpleEntity();
s.save(de);
// Read
SimpleEntity de2 = (SimpleEntity) s.load(SimpleEntity.class, de
.getEntityPK());
assertNotNull(de2);
assertEquals(de, de2);
// Query
Criteria crit = s.createCriteria(SimpleEntity.class);
List results = crit.list(); // FAILING!!! IllegalArgumentException in class: it.unimaticaspa.unique.pe.spec.entity.EntityBase, setter method of property: entityPK
// expected type: it.unimaticaspa.unique.pe.spec.entity.IEntityPK, actual value: java.lang.Long
Logs :
IllegalArgumentException in class: it.unimaticaspa.unique.pe.spec.entity.EntityBase, setter method of property: entityPK
expected type: it.unimaticaspa.unique.pe.spec.entity.IEntityPK, actual value: java.lang.Long
Error StackTrace:
org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of it.unimaticaspa.unique.pe.spec.entity.EntityBase.entityPK
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.setIdentifier(AbstractEntityTuplizer.java:211)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.instantiate(AbstractEntityTuplizer.java:353)
at org.hibernate.persister.entity.AbstractEntityPersister.instantiate(AbstractEntityPersister.java:3600)
at org.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1275)
...
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
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.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42)
... 35 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
18 years, 6 months
[Hibernate-JIRA] Created: (HHH-2034) Potential ClassCastException in catch block in NullableType
by Galen Palmer (JIRA)
Potential ClassCastException in catch block in NullableType
-----------------------------------------------------------
Key: HHH-2034
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2034
Project: Hibernate3
Type: Improvement
Components: core
Versions: 3.1.3
Environment: Hibernate 3.1.3
Reporter: Galen Palmer
Priority: Minor
It is possible to throw an exception from within the catch block of NullableType.nullSafeSet() since the toString(value) method calls in many cases (e.g. StringType) simply result in a cast of return (String)value. This may mask the underlying problem for the users.
A proposed solution would be to replace the call in the catch blog of toString(value) with a reference to value. For example:
line 87:
log().info( "could not bind value '" + value + "' to parameter: " + index + "; " + re.getMessage() );
and line 91:
log().info( "could not bind value '" + value + "' to parameter: " + index + "; " + se.getMessage() );
This change would prevent the catch block from throwing the exception.
--
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, 6 months
[Hibernate-JIRA] Created: (ANN-571) Missing referencedColumnName in @JoinColumn doesn't cause an error
by Brian Curnow (JIRA)
Missing referencedColumnName in @JoinColumn doesn't cause an error
------------------------------------------------------------------
Key: ANN-571
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-571
Project: Hibernate Annotations
Type: Bug
Versions: 3.2.1
Environment: Hibernate 3.3.2, Oracle 9.2 (JDBC Thin XA driver version 10.2.0.2.0)
Running in WebLogic Server 9.2 MP1 on Solaris 8 and JDK 1.5.0_10
Reporter: Brian Curnow
According to the JPA specification (p. 169) if there are multiple @JoinColumn annotations specified within an @JoinColumns annotation then both name and referencedColumnName attributes must be used:
"If there is more than one join column, a JoinColumn annotation must be specified for each join column
using the JoinColumns annotation. Both the name and the referencedColumnName elements
must be specified in each such JoinColumn annotation."
Right now, if I leave off the referencedColumnName everything appears to work but I get some random SQL. For instance, say I have two tables TABLE1 and TABLE2 and they are joined on the columns ID and TYPE, sometimes I get the right join condition:
TABLE1.ID = TABLE2.ID AND TABLE1.TYPE = TABLE2.TYPE
but sometimes I get:
TABLE1.ID = TABLE2.TYPE AND TABLE1.TYPE = TABLE2.ID
Adding the referencedColumnName makes that issue go away.
Since the spec says that those two attributes are required there really should be a runtime check for that which, at the very least, puts a warning in the log. I'd prefer a RuntimeException so you can't accidentally violate the spec.
--
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, 6 months