[Hibernate-JIRA] Created: (HHH-3824) OneToOne join by Non-primary key column throws PropertyAccessException when join column is String
by sathish (JIRA)
OneToOne join by Non-primary key column throws PropertyAccessException when join column is String
-------------------------------------------------------------------------------------------------
Key: HHH-3824
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3824
Project: Hibernate Core
Issue Type: Bug
Components: query-criteria, query-hql
Affects Versions: 3.3.1
Environment: Microsoft SQL server 2005, Hibernate 3.3.1
Reporter: sathish
Attachments: trace.txt
When i try to join 2 entities by OneToOne using a Non-primary key column, it throws the following exception:
org.hibernate.PropertyAccessException: could not get a field value by reflection getter of com.xxx.domain.Inventory.sku
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.String field com.inwk.estore.server.domain.Inventory.sku to java.lang.Integer
[Full stacktrace attached]
sku is the Non-primary key String join column by which im trying to do a OneToOne join between Item and Inventory entity.
Apparently its trying to interpret Sku as an Integer column. Adding columnDefinition as VARCHAR/String doesn't help either
Mappings for Item and Inventory are below:
class Item{
@Id
Long id;
@Column
String sku;
//some more properties
@OneToOne(optional = true)
@JoinColumn(name = "sku", referencedColumnName = "sku", insertable = false, updatable = false)
Inventory inventory;
}
class Inventory{
@Id
Long id
@Column
String sku
@Column
Long quantity;
}
--
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-4581) Embedded objects in criteria API does not work
by Jaroslaw Lewandowski (JIRA)
Embedded objects in criteria API does not work
----------------------------------------------
Key: HHH-4581
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4581
Project: Hibernate Core
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.5.0-Beta-2
Reporter: Jaroslaw Lewandowski
It not possible to use Embedded attribute in Criteria API. E.g. having the following entity
@Entity
class Client {
@Embedded
private Name name;
}
@Embeddable
public class Name implements Serializable {
@Basic
private String firstName;
@Basic
private String lastName;
}
The following throws an exception
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<ClientCard> cq = cb.createQuery(Client.class);
Root<ClientCard> root = cq.from(ClientCard.class);
cq.where(cb.equal(root.get(Client_.name).get(Name_.firstName)), "blah");
em.createQuery(cq).getResultList();
Saying that Name is not managed entity:
Caused by: java.lang.IllegalArgumentException: Not an managed type: class com.phorest.memento.server.domain.Name
at org.hibernate.ejb.metamodel.MetamodelImpl.managedType(MetamodelImpl.java:171)
at org.hibernate.ejb.criteria.JoinImpl.<init>(JoinImpl.java:54)
at org.hibernate.ejb.criteria.FromImpl.constructJoin(FromImpl.java:193)
at org.hibernate.ejb.criteria.FromImpl.join(FromImpl.java:176)
at org.hibernate.ejb.criteria.FromImpl.join(FromImpl.java:169)
at org.hibernate.ejb.criteria.FromImpl.get(FromImpl.java:559)
--
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-3007) Unchanged persistent set gets marked dirty on session.merge()
by Lars Koedderitzsch (JIRA)
Unchanged persistent set gets marked dirty on session.merge()
-------------------------------------------------------------
Key: HHH-3007
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3007
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.5
Reporter: Lars Koedderitzsch
Persistent sets are marked dirty on session.merge() even if there have been no changes to the collection.
This is especially painful when the collection is immutable and results in an "changed an immutable collection instance" exception on flush.
I tracked the behaviour down a bit and believe the problem to be in CollectionType.replace().
Here the passed in orginal PersistentSet is replaced by a plain HashSet in this line:
Object result = target == null || target == original ? instantiateResult( original ) : target;
The "result" object (HashSet) is then passed to the CollectionType.replaceElements() method (instead of the original PersistentSet).
In CollectionType.replaceElements() the code to clear the dirty state of the collection does not execute anymore, because the passed-in "original" collection is the described HashSet and *not* the original PersistentSet.
This way the PersistentSet remains marked dirty.
A workaround is to manually clear the dirty state of an immutable collection after merge but before flush.
--
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-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, 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