[Hibernate-JIRA] Commented: (HBX-621) meta attribute of scope-get/set & inherit bug
by Rob Jellinghaus (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-621?page=co... ]
Rob Jellinghaus commented on HBX-621:
-------------------------------------
Max, please consider this verified. I have the exact same problem. Here's a fragment of a mapping:
<hibernate-mapping default-lazy="false">
<class name="com.nimblefish.core.domain.configuration.Configuration">
<meta attribute="generated-class">com.nimblefish.core.domain.generated.ConfigurationGen</meta>
<meta attribute="scope-class" inherit="false">public abstract</meta>
<meta attribute="scope-set">protected</meta>
...
<!-- all configurations have codes, really -->
<property name="code" type="string">
<meta attribute="use-in-tostring">true</meta>
<meta attribute="scope-set">public</meta>
</property>
...
And here's a fragment of the POJO created by hibernatetool's hbm2java:
package com.nimblefish.core.domain.generated;
// Generated Oct 27, 2006 2:43:27 PM by Hibernate Tools 3.2.0.beta8
import com.nimblefish.core.domain.configuration.FrozenConfigurationHolder;
import com.nimblefish.core.domain.engine.Engine;
import java.util.HashMap;
import java.util.Map;
/**
* ConfigurationGen generated by hbm2java
*/
public abstract class ConfigurationGen implements java.io.Serializable {
...
protectedpublic void setCode(String code) {
this.code = code;
}
Definitely a bug, and a painful one to fix, since now I have to go through and remove ALL of the <meta attribute="scope-set"> tags on ALL of the classes that override the setter scope for individual fields :-P Please fix it for Hibernate Tools 3.2GA!
> meta attribute of scope-get/set & inherit bug
> ---------------------------------------------
>
> Key: HBX-621
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-621
> Project: Hibernate Tools
> Type: Bug
> Versions: 3.1beta4
> Environment: Hiberante 3.1.2
> Hibernate Tools 3.1 beta 4
> Reporter: Neil Buesing
> Fix For: 3.2beta9
>
>
> An inhertiable class level meta attribute of scope-get and scope-set cannot be overridden within a property. Instead some string concat is being applied. This is different behavior than with hibernate tools 2.1.3 and it is a potential bug (or at least a change of behavior).
> Hibernate 3 Mapping File
> <?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.hibernate">
> <class mutable="true" lazy="false" name="com.hibernate.Test" table="TEST">
> <meta attribute="scope-get">private</meta>
> <meta attribute="scope-set">private</meta>
> <id name="id" column="ID" type="long">
> <generator class="assigned" />
> </id>
> <property name="col1" column="COL1" type="java.lang.String">
> <meta attribute="scope-get">public</meta>
> </property>
> <property name="col2" column="COL2" type="java.lang.String">
> <meta attribute="scope-set"></meta>
> <meta attribute="scope-get">public</meta>
> </property>
> <property name="col3" column="COL3" type="java.lang.String">
> </property>
> <property name="col4" column="COL4" type="java.lang.String">
> </property>
> </class>
> </hibernate-mapping>
> Hibernate 3 Generated File
> package com.hibernate;
> // Generated Mar 16, 2006 10:00:19 AM by Hibernate Tools 3.1.0.beta4
> /**
> * Test generated by hbm2java
> */
> public class Test implements java.io.Serializable {
> // Fields
> private long id;
> private String col1;
> private String col2;
> private String col3;
> private String col4;
> // Constructors
> /** default constructor */
> public Test() {
> }
> /** minimal constructor */
> public Test(long id) {
> this.id = id;
> }
>
> /** full constructor */
> public Test(long id, String col1, String col2, String col3, String col4) {
> this.id = id;
> this.col1 = col1;
> this.col2 = col2;
> this.col3 = col3;
> this.col4 = col4;
> }
>
> // Property accessors
> privatepublicpublic long getId() {
> return this.id;
> }
>
> private void setId(long id) {
> this.id = id;
> }
> privatepublicpublic String getCol1() {
> return this.col1;
> }
>
> private void setCol1(String col1) {
> this.col1 = col1;
> }
> privatepublicpublic String getCol2() {
> return this.col2;
> }
>
> private void setCol2(String col2) {
> this.col2 = col2;
> }
> privatepublicpublic String getCol3() {
> return this.col3;
> }
>
> private void setCol3(String col3) {
> this.col3 = col3;
> }
> privatepublicpublic String getCol4() {
> return this.col4;
> }
>
> private void setCol4(String col4) {
> this.col4 = col4;
> }
> }
> Hibernate 2 Mapping File
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
> "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
> <hibernate-mapping package="com.hibernate">
> <class mutable="true" lazy="false" name="com.hibernate.Test" table="TEST">
> <meta attribute="scope-get">private</meta>
> <meta attribute="scope-set">private</meta>
> <id name="id" column="ID" type="long">
> <generator class="assigned" />
> </id>
> <property name="col1" column="COL1" type="java.lang.String">
> <meta attribute="scope-get">public</meta>
> </property>
> <property name="col2" column="COL2" type="java.lang.String">
> <meta attribute="scope-set"></meta>
> <meta attribute="scope-get">public</meta>
> </property>
> <property name="col3" column="COL3" type="java.lang.String">
> </property>
> <property name="col4" column="COL4" type="java.lang.String">
> </property>
> </class>
> </hibernate-mapping>
> Hibernate 2 Generated File
> package com.hibernate;
> import java.io.Serializable;
> import org.apache.commons.lang.builder.ToStringBuilder;
> /** @author Hibernate CodeGenerator */
> public class Test implements Serializable {
> /** identifier field */
> private Long id;
> /** nullable persistent field */
> private String col1;
> /** nullable persistent field */
> private String col2;
> /** nullable persistent field */
> private String col3;
> /** nullable persistent field */
> private String col4;
> /** full constructor */
> public Test(Long id, String col1, String col2, String col3, String col4) {
> this.id = id;
> this.col1 = col1;
> this.col2 = col2;
> this.col3 = col3;
> this.col4 = col4;
> }
> /** default constructor */
> public Test() {
> }
> /** minimal constructor */
> public Test(Long id) {
> this.id = id;
> }
> private Long getId() {
> return this.id;
> }
> private void setId(Long id) {
> this.id = id;
> }
> public String getCol1() {
> return this.col1;
> }
> private void setCol1(String col1) {
> this.col1 = col1;
> }
> public String getCol2() {
> return this.col2;
> }
> void setCol2(String col2) {
> this.col2 = col2;
> }
> private String getCol3() {
> return this.col3;
> }
> private void setCol3(String col3) {
> this.col3 = col3;
> }
> private String getCol4() {
> return this.col4;
> }
> private void setCol4(String col4) {
> this.col4 = col4;
> }
> public String toString() {
> return new ToStringBuilder(this)
> .append("id", getId())
> .toString();
> }
> }
> see also forum topic http://forum.hibernate.org/viewtopic.php?t=956894#2296725
--
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
19 years, 5 months
[Hibernate-JIRA] Created: (HHH-2192) Collections can be cached with uncommitted members
by Owen Taylor (JIRA)
Collections can be cached with uncommitted members
--------------------------------------------------
Key: HHH-2192
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2192
Project: Hibernate3
Type: Bug
Components: core
Reporter: Owen Taylor
org.hibernate.TreeCache.put() does the put into the database with the current transaction
suspended. This works well for entities, because Hibernate knows authorittaively whether
the entity has previously been modified in the current transaction and will never put() an
entity into the cache if it has already modified it in the current transaction. However, the same
is not true for collections; there are cases where data from the current transaction can be
stored into the treecache with a put() as the example below demonstrates:
(Using EJB3 to describe the issue but this is not EJB3 specific, I just don't know the equivalent
raw Hibernate well)
@Entity
public class Account {
[...];
@OneToMany(mappedBy="account")
@Cache(usage=CacheConcurrencyStrategy.TRANSACTIONAL)
Set<Client> clients;
}
@Entity
public class Client {
[...];
@ManyToOne
@JoinColumn(nullable=false);
Account account;
}
// account.clients is set to a persistent collection, but not yet loaded
Account account = em.find(account_id);
Client client = new Client(account);
// The new client may be inserted into the database at this point
em.persist(client);
// First account.clients is loaded, *including* the newly created client, and
// immediately stored into the tree cache, bypassing the current transaction
// Other threads now have visibility to the collection including the item
// not yet committed to the database
//
// Then it is modified to add the new client which causes an eviction of
// the collections node from the cache *within* the current transaction, but
// that eviction will be rolled back if the transaction is rolled back and
// also isn't propagated to other cluster nodes until commit
account.clients.add(client);
// Now the transaction will be rolled back, so the new client is never committed,
// but the updated collection will still be in the treecache
em.getTransaction().setRollbackOnly()
It's fairly simple to fix the particular case above because we initialize the collection
inside add(), so we could avoid caching the loaded values, however there are
slightly more artificial cases that are harder to fix, for example:
if (!account.clients.contains(client))
account.clients.add(client);
One general fix would be when evicting a node that we *haven't* previously
read from the cache or modified in the current transaction to bypass the current
transaction when evicting it. That condition is important, since if the tx has a
read or write lock on the node, trying to evict it with the tx suspsended will
dead-lock. (Does JBossCache have a way of querying whether the tx has
a lock on a node?)
Or maybe there is something simpler that I haven't thought of.
P.S. I think this problem is exclusive to TransactionalCache; for ReadWriteCache,
evictions remove the item from the cache without regard to transactions.
--
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
19 years, 5 months