[Hibernate-JIRA] Created: (HHH-3459) NullPointerException in Formatter.isFunctionName with certain SQL when pretty format is used
by Scott Feldstein (JIRA)
NullPointerException in Formatter.isFunctionName with certain SQL when pretty format is used
--------------------------------------------------------------------------------------------
Key: HHH-3459
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3459
Project: Hibernate3
Issue Type: Bug
Components: query-sql
Affects Versions: 3.2.6
Reporter: Scott Feldstein
A NullPointerException is thrown when hibernate.show_sql=true && hibernate.format_sql=true while exec'ing sql with quotes around the stmt:
(taken from an embedded groovy script)
---------
def sess = getSession()
def HQL = """
(select count(*) from TABLE)
"""
sess
.createSQLQuery(HQL)
.list()
------------
This is valid SQL and is typically used in my app as such:
(select count(*) from TABLE1) UNION ALL (select count(*) from TABLE2) ...
Here is the stack trace in hibernate:
java.lang.NullPointerException
at org.hibernate.pretty.Formatter.isFunctionName(Formatter.java:342)
at org.hibernate.pretty.Formatter.openParen(Formatter.java:323)
at org.hibernate.pretty.Formatter.format(Formatter.java:134)
at org.hibernate.jdbc.AbstractBatcher.format(AbstractBatcher.java:410)
at org.hibernate.jdbc.AbstractBatcher.log(AbstractBatcher.java:404)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:482)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:423)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
at org.hibernate.loader.Loader.doQuery(Loader.java:673)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
--
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, 2 months
[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, 2 months
[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, 2 months
[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, 2 months