[Hibernate-JIRA] Created: (HHH-6178) Mapping bidirectional one-to-one relationship fails with an AnnotationException: Unknown mappedBy in: / referenced property unknown
by Karsten Wutzke (JIRA)
Mapping bidirectional one-to-one relationship fails with an AnnotationException: Unknown mappedBy in: / referenced property unknown
-----------------------------------------------------------------------------------------------------------------------------------
Key: HHH-6178
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6178
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.0
Environment: Hibernate 3.6.0 Final, HSQLDB 2.0.1 RC, JavaSE
Reporter: Karsten Wutzke
Priority: Critical
Mapping a simple bidirectional one-to-one relationship fails with an AnnotationException for no obvious reason.
DB design:
CREATE TABLE Persons
(
id INTEGER NOT NULL,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE Coaches
(
id INTEGER NOT NULL,
license_nbr VARCHAR(10) DEFAULT NULL NULL,
PRIMARY KEY (id),
FOREIGN KEY (id) REFERENCES Persons (id)
);
CREATE TABLE Players
(
id INTEGER NOT NULL,
registration_nbr VARCHAR(20) DEFAULT NULL NULL,
PRIMARY KEY (id),
FOREIGN KEY (id) REFERENCES Persons (id)
);
Mappings (relevant shown only):
@Entity
@Table(name = "Persons")
public class Person implements Serializable
{
@Id
@Column(name = "id")
private Integer id;
@Column(name = "first_name")
private String firstName;
@Column(name = "last_name")
private String lastName;
@OneToOne(mappedBy = "person")
private Coach coach = null;
@OneToOne(mappedBy = "person")
private Player player = null;
...
}
@Entity
@Table(name = "Players")
public class Player implements Serializable
{
@Column(name = "registration_nbr")
private String registrationNbr = null;
@Id
@OneToOne
@JoinColumn(name = "id")
private Person person = null;
...
}
@Entity
@Table(name = "Coaches")
public class Coach implements Serializable
{
@Column(name = "license_nbr")
private String licenseNbr = null;
@Id
@OneToOne
@JoinColumn(name = "id")
private Person person = null;
...
}
The exception thrown in a test app:
Exception in thread "main" javax.persistence.PersistenceException: [PersistenceUnit: persons] Unable to configure EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:374)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
at tld.persons.Main.main(Main.java:34)
Caused by: org.hibernate.AnnotationException: Unknown mappedBy in: tld.persons.model.Person.coach, referenced property unknown: tld.persons.model.Coach.person
at org.hibernate.cfg.OneToOneSecondPass.doSecondPass(OneToOneSecondPass.java:159)
at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1686)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1393)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1345)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1477)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:193)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1096)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:278)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:362)
... 4 more
This exception is really surprising given the simplicity of this design. I've also tested this with EclipseLink which has no problems with the mappings.
I'll attach an test case including the full code.
--
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
13 years, 1 month
[Hibernate-JIRA] Created: (HHH-6296) Unnecessary lock in UpdateTimestampsCache
by Alexandre Thiel (JIRA)
Unnecessary lock in UpdateTimestampsCache
-----------------------------------------
Key: HHH-6296
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6296
Project: Hibernate Core
Issue Type: Patch
Components: caching (L2)
Affects Versions: 3.6.4, 3.6.3, 3.6.2, 3.6.1
Environment: Hibernate 3.6.4
Reporter: Alexandre Thiel
Priority: Minor
Attachments: UpdateTimestampsCache.java.diff
Non transactional queries call UpdateTimestmapsCache.invalidate method with an empty array parameter but still acquire a WriteLock which cause a performance bottle neck under heavy load.
GNU-Diff Patch for org.hibernate.cache.UpdateTimestampsCache attached
Thread dump example :
"TP-Processor10" daemon prio=10 tid=0x00000000415cb800 nid=0x6803 waiting on condition [0x00007f1346594000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00007f1370f6d1c0> (a java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:778)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1114)
at java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock.lock(ReentrantReadWriteLock.java:807)
at org.hibernate.cache.UpdateTimestampsCache.invalidate(UpdateTimestampsCache.java:88)
at org.hibernate.engine.ActionQueue$AfterTransactionCompletionProcessQueue.afterTransactionCompletion(ActionQueue.java:604)
at org.hibernate.engine.ActionQueue.afterTransactionCompletion(ActionQueue.java:209)
at org.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:602)
at org.hibernate.jdbc.JDBCContext.afterNontransactionalQuery(JDBCContext.java:292)
at org.hibernate.impl.SessionImpl.afterOperation(SessionImpl.java:595)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:993)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:978)
--
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
13 years, 1 month
[Hibernate-JIRA] Created: (HHH-5857) SQLServer dialect for varbinary incorrect for 2008
by Steve Mactaggart (JIRA)
SQLServer dialect for varbinary incorrect for 2008
--------------------------------------------------
Key: HHH-5857
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5857
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.0
Reporter: Steve Mactaggart
In SQLServer 2008 the IMAGE data type has been deprecated and replaced with VARBINARY(MAX)
{quote}
ntext, text, and image data types will be removed in a future version of Microsoft SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead. For more information, see Using Large-Value Data Types.
{quote}
The current SQLServer2008Dialect has the mapping (inherirted from SQLServerDialect):
{code}
registerColumnType( Types.VARBINARY, "image" );
{code}
This needs to be reverted to use VARBINARY.
{code}
registerColumnType( Types.VARBINARY, "varbinary" );
{code}
The issue is identified when using hibernate.ddl.auto=validate, it shows an error such as:
{quote}
Wrong column type in Database.dbo.BINARY_OBJECT for column BYTES. Found: varbinary, expected: image
{quote}
for an annotated fields such as:
{code}
@Column(name = "BYTES", length = 100000, nullable = true)
private byte[] bytes;
{code}
--
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
13 years, 1 month
[Hibernate-JIRA] Created: (HHH-5421) Accessing collection on PostLoad event causes LazyInitializationException
by Stu White (JIRA)
Accessing collection on PostLoad event causes LazyInitializationException
-------------------------------------------------------------------------
Key: HHH-5421
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5421
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.5.3
Environment: Hibernate-3.5.3-Final
Oracle 11g
Reporter: Stu White
Attachments: hibernate-test.zip
We've encountered a problem using the PostLoad event to access a OneToMany Collection.
Attempting to access the Collection in the PostLoad event handler results in a LazyInitializationException being thrown by AbstractEntityManagerImpl. The stack trace is below:
javax.persistence.PersistenceException: org.hibernate.LazyInitializationException: failed to lazily initialize a collection, no session or session was closed
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1235)
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:631)
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:585)
I've attached a JUnit test case containing the classes and configuration. We're using Oracle 11g and Hibernate v3.5.3-Final, but the test case uses HSQLDB.
If there is any further information I can provide to help diagnose this then please let me know.
--
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
13 years, 1 month