[Hibernate-JIRA] Created: (HHH-3527) Null Version Comparator for versioned class due to reuse of Second Level CacheDataDescriptionImpl
by Paul FitzPatrick (JIRA)
Null Version Comparator for versioned class due to reuse of Second Level CacheDataDescriptionImpl
-------------------------------------------------------------------------------------------------
Key: HHH-3527
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3527
Project: Hibernate Core
Issue Type: Bug
Components: caching (L2)
Affects Versions: 3.3.1
Environment: 3.3.1 GA, Postgres 8.3.3, EH Cache
Reporter: Paul FitzPatrick
Priority: Minor
When the SessionFactoryImpl constructor builds the EntityPersister for classes, it consults a cache of entityAccessStrategies for all the known second level cache regions. If only some of the classes in that region have version tags, then it is possible the cached EntityRegionAccessStrategy will be created without a Version Comparator. Subsequent calls to load an object using a Criteria query failed with a NullPointerException (stack trace below). The line being executed is "return version!=null && comparator.compare(version, newVersion) < 0;" and in this case "version" is an Integer object and comparator is null.
Not sure the appropriate solution. It would seem from an examination of the code that if the EntityRegionAccessStrategy is to be shared, then all classes in the second level cache region _must_ either all have a "version" column or all have no "version" column. Further, it seems implied that if they use a "version" column, then they must all use the exact same data type. If this is the case, then a better error check on the configuration data may be in order.
Caused by: java.lang.NullPointerException
at org.hibernate.cache.ReadWriteCache$Item.isPuttable(ReadWriteCache.java:426)
at org.hibernate.cache.ReadWriteCache.put(ReadWriteCache.java:180)
at org.hibernate.cache.impl.bridge.EntityAccessStrategyAdapter.putFromLoad(EntityAccessStrategyAdapter.java:68)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:179)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:877)
at org.hibernate.loader.Loader.doQuery(Loader.java:752)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1596)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:328)
--
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
[Hibernate-JIRA] Created: (HHH-5202) polymorphism=PolymorphismType.EXPLICIT not work
by zhuzhangsuo (JIRA)
polymorphism=PolymorphismType.EXPLICIT not work
------------------------------------------------
Key: HHH-5202
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5202
Project: Hibernate Core
Issue Type: Bug
Components: annotations
Affects Versions: 3.5.1
Environment: hibernate3.5.1 mysql 5.1
Reporter: zhuzhangsuo
Attachments: src.rar
class Book ,Section is Inheritanced from EntityItem and use @Inheritance(strategy=InheritanceType.JOINED)
I want to use @org.hibernate.annotations.Entity(dynamicUpdate=true,selectBeforeUpdate=true, polymorphism=PolymorphismType.EXPLICIT) to select the base table into EntityItem but not Book or Section
The sql is : select entityitem0_.entity_id as entity1_0_, entityitem0_.entity_author as entity2_0_, entityitem0_.entity_category as entity3_0_, entityitem0_.entity_ctime as entity4_0_, entityitem0_.entity_desc as entity5_0_, entityitem0_.entity_folder as entity6_0_, entityitem0_.entity_keyword as entity7_0_, entityitem0_.entity_name as entity8_0_, entityitem0_.entity_operator as entity9_0_, entityitem0_.entity_order as entity10_0_, entityitem0_.entity_pid as entity18_0_, entityitem0_.entity_picture as entity11_0_, entityitem0_.entity_status as entity12_0_, entityitem0_.entity_tag as entity13_0_, entityitem0_.entity_template as entity14_0_, entityitem0_.entity_type as entity15_0_, entityitem0_.entity_update_time as entity16_0_, entityitem0_.entity_url as entity17_0_, entityitem0_1_.section_content as section1_1_, entityitem0_2_.book_continue as book1_2_, entityitem0_2_.book_copyright as book2_2_, entityitem0_2_.book_grade as book3_2_, entityitem0_2_.book_press as book4_2_, entityitem0_2_.book_price as book5_2_, entityitem0_2_.book_pv as book6_2_, entityitem0_2_.book_translate as book7_2_, case when entityitem0_1_.entity_id is not null then 1 when entityitem0_2_.entity_id is not null then 2 when entityitem0_.entity_id is not null then 0 end as clazz_ from book_entity entityitem0_ left outer join book_section_detail entityitem0_1_ on entityitem0_.entity_id=entityitem0_1_.entity_id left outer join book_detail entityitem0_2_ on entityitem0_.entity_id=entityitem0_2_.entity_id
--
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, 1 month
[Hibernate-JIRA] Created: (HV-230) Database Connective or @Unique
by Ken Egervari (JIRA)
Database Connective or @Unique
------------------------------
Key: HV-230
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-230
Project: Hibernate Validator
Issue Type: New Feature
Affects Versions: 3.1.0.GA
Reporter: Ken Egervari
Priority: Critical
I find a common validation use case is checking to see if a field is unique to all those in the table, such as emails, isbns, usernames, keywords, etc. these fields may not be the primary key, but still need to be unique.
It would be fantastic if hibernate validator implemented this.
This is a common problem though because the domain class will need to have access the database. I dunno if there's an easy way to wire in a copy of sessionFactory to make this easy to write.
Perhaps something like this:
@Query( "select user from User user where user.emailAddress = :this.emailAddress and user.id != :this.id", message = "That Email is already being used by another user in the system" )
private String emailAddress;
Basically the idea is that if @Query returns no results, then the validation constraint is good, and if returns more than 1 result, then it fails. Kind of like simpleJdbcTemplate.queryForMap() does within the Spring testing framework. That method causes the test to fail if no row is returned, because it expects 1 result.
If it were possible to just say
@Unique
private String emailAddress;
That would be extremely concise and would save people a ton of time.
Of course, this requires some interoperability with Hibernate... but I think that's a good thing, no?
Thanks for taking this into consideration. I'd appreciate an email letting me know how to do this in a clean way in 3.1.0 GA as it is as well if you would. Thank you.
--
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, 1 month
[Hibernate-JIRA] Created: (HHH-4795) Comparing OneToOne mappedBy column to null generates wrong SQL
by Uros Majeric (JIRA)
Comparing OneToOne mappedBy column to null generates wrong SQL
--------------------------------------------------------------
Key: HHH-4795
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4795
Project: Hibernate Core
Issue Type: Bug
Environment: Hibernate core 3.3.2.GA
Postgresql 8.4
Reporter: Uros Majeric
I have two entities:
@Entity
@Table(name = "beer_keg")
public class Keg implements Serializable {
@Id
@GeneratedValue
@Column(name = "bkid")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@OneToOne(mappedBy="keg", fetch=FetchType.LAZY, optional=true)
public KegValveCombination getCombination() {
return combination;
}
void setCombination(KegValveCombination combination) {
this.combination = combination;
}
}
and
@Entity
@Table(name="keg_valve_combination")
public class KegValveCombination implements Serializable {
@Id
@GeneratedValue
@Column(name="id", nullable=false)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@OneToOne(cascade=CascadeType.ALL)
@JoinColumn(name="keg", nullable=false, unique=true)
public Keg getKeg() {
return keg;
}
public void setKeg(Keg keg) {
this.keg = keg;
}
}
if I create query:
em.createQuery("FROM Keg k WHERE k.combination is null").getResultList();
hibernate generates sql like:
select keg0_.* from beer_keg keg0_ where keg0_.bkid is null
but it should be:
select keg0_.* from beer_keg keg0_ left join keg_valve_combination kegvalveco1_ on keg0_.bkid=kegvalveco1_.keg where (kegvalveco1_.keg is null)
thanks, Uros
--
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, 1 month
[Hibernate-JIRA] Created: (HHH-4453) Reserved keywords not quoted in table/column names
by Philipp Reichart (JIRA)
Reserved keywords not quoted in table/column names
--------------------------------------------------
Key: HHH-4453
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4453
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Environment: Hibernate 3.3.1 GA, Windows XP, Sun JDK 1.6.0_06, Derby 10.5
Reporter: Philipp Reichart
I'm currently migrating our test suite form HSQLDB to Derby (we need transaction isolation and the HSLDB 1.9 RCs are no good), and found out that we have a lot of table or colum names that happen to be reserved keywords in Derby, like "transaction", "key", "value", "year", etc..
The usual workaround seems to be adding backticks to any offending table/column name in our hbm.xml files, but that's really an ugly workaround and doesn't prevent later incidents of this kind when new keywords show up in either our mappings or database. As this is about a production database schema, reanming the table/column names isn't an option either.
I already tried implementing a custom Derby dialect and registering all the keywords from the Derby doc at http://db.apache.org/derby/docs/10.5/ref/rrefkeywords29722.html and even defined a "quote everything" NamingStrategy using the dialect to get the correct native quotes for the database.
Unfortunately, neither the Hibernate DDL generator nor HQL queries seem to consider the naming strategy or dialect when handling table or column names.
Is there any way to have Hibernate quote database-specific keywords every they're used?
Or just have Hibernate quote everything that comes from a mapping file?
--
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, 1 month