[Hibernate-JIRA] Created: (HHH-3507) MultipleHiLoPerTableGenerator can contain stale hi value, generate duplicate IDs
by Christopher Wong (JIRA)
MultipleHiLoPerTableGenerator can contain stale hi value, generate duplicate IDs
--------------------------------------------------------------------------------
Key: HHH-3507
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3507
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.0.SP1
Environment: Hibernate 3.3.0SP1 on MySQL 5.0.37-community-nt
Reporter: Christopher Wong
An instance of MultipleHiLoPerTableGenerator seems to be created per table (and per schema?). This instance seems to persist across DB sessions/transactions, retaining the "hi" value that it last loaded from the generator table. The problem comes when the generator retains this "hi" value across a DB reset. It is not unusual to reinitialize a schema for a new customer, or to restore a backup dump. The problem is that when a DB is reset, this "hi" value is no longer valid, causing the IDs to wrap around and eventually duplicate. Example sequence:
generate ID 195
generate ID 196
<DB reset.>
generate ID 197
generate ID 198
generate ID 199
<max lo reached. Load new "hi" value from DB.>
generate ID 1
generate ID 2
... (etc) ...
generate ID 196
generate ID 197 (ID is now duplicated, causing NonUniqueObjectException)
Perhaps the generator can recheck the generator table at the beginning of a transaction to ensure its hi value is consistent.
--
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-3505) OptimizerFactory$HiLoOptimizer doesn't move internal idvalue to new slot when hiValue is reached
by Björn Schmidt (JIRA)
OptimizerFactory$HiLoOptimizer doesn't move internal idvalue to new slot when hiValue is reached
------------------------------------------------------------------------------------------------
Key: HHH-3505
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3505
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.2.4
Environment: Hibernate 3.2.4
Reporter: Björn Schmidt
When the currently generated id-value has reached the TableGenerator's hivalue, all that is updated is the hivalue which is read in via the nextValue() callback. But the current idvalue needs to be readjusted to a new slot according to the new hiValue, because otherwise it may run into slots already assigned to and used by other applications. In our case, we got massive amounts of unique constraint-violations on many primarykey columns.
Original Source:
public synchronized Serializable generate(AccessCallback callback) {
if ( lastSourceValue < 0 ) {
lastSourceValue = callback.getNextValue();
while ( lastSourceValue <= 0 ) {
lastSourceValue = callback.getNextValue();
}
hiValue = ( lastSourceValue * incrementSize ) + 1;
value = hiValue - incrementSize;
}
else if ( value >= hiValue ) {
lastSourceValue = callback.getNextValue();
hiValue = ( lastSourceValue * incrementSize ) + 1;
}
return make( value++ );
}
This should look like:
public synchronized Serializable generate(AccessCallback callback) {
if ( lastSourceValue < 0 ) {
lastSourceValue = callback.getNextValue();
while ( lastSourceValue <= 0 ) {
lastSourceValue = callback.getNextValue();
}
hiValue = ( lastSourceValue * incrementSize ) + 1;
value = hiValue - incrementSize;
}
else if ( value >= hiValue ) {
lastSourceValue = callback.getNextValue();
hiValue = ( lastSourceValue * incrementSize ) + 1;
// Adjust value to new Idslot.
------> value = hiValue - incrementSize;
}
return make( value++ );
}
--
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-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] Updated: (EJB-204) ClassCastException when using <mapped-superclass> in orm.xml
by Gail Badner (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/EJB-204?page=co... ]
Gail Badner updated EJB-204:
----------------------------
Comment: was deleted
> ClassCastException when using <mapped-superclass> in orm.xml
> ------------------------------------------------------------
>
> Key: EJB-204
> URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-204
> Project: Hibernate Entity Manager
> Issue Type: Bug
> Components: EntityManager
> Affects Versions: 3.2.0.cr1
> Environment: Hibernate 3.2.0 cr2, EntityManager 3.2.0 cr1 and Annotations 3.2.0 cr1
> Reporter: Levi Purvis
> Priority: Minor
> Fix For: 3.2.0.cr2
>
>
> Using a <mapped-superclass> element in orm.xml will generate the following exception:
> javax.persistence.PersistenceException: java.lang.ClassCastException: $Proxy0
> at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:217)
> at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
> at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
> at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27)
> ......
> Caused by: java.lang.ClassCastException: $Proxy0
> at org.hibernate.reflection.java.EJB3OverridenAnnotationReader.getMappedSuperclass(EJB3OverridenAnnotationReader.java:1688)
> at org.hibernate.reflection.java.EJB3OverridenAnnotationReader.initAnnotations(EJB3OverridenAnnotationReader.java:285)
> at org.hibernate.reflection.java.EJB3OverridenAnnotationReader.isAnnotationPresent(EJB3OverridenAnnotationReader.java:257)
> at org.hibernate.reflection.java.JavaXAnnotatedElement.isAnnotationPresent(JavaXAnnotatedElement.java:40)
> at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:237)
> at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1034)
> at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1015)
> at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
> at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:751)
> at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:151)
> at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:205)
> ... 19 more
> Also see the following thread:
> http://forum.hibernate.org/viewtopic.php?t=960744
--
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