[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, 5 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, 5 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, 5 months
[Hibernate-JIRA] Created: (HHH-6003) Envers fails when an entity has dynamic-component
by Rajeev (JIRA)
Envers fails when an entity has dynamic-component
-------------------------------------------------
Key: HHH-6003
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6003
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.6.0
Environment: Windows 7, java version "1.6.0_18" (32 bit), hibernate-core-3.6.0.Final, mysql-5.1.45-win32
Reporter: Rajeev
Attachments: myproject.tar
hi,
Am working with hibernate version 3.6.0.Final. Envers fails during initialization when an entity has dynamic-component.
Hibernate.cfg.xml -
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/company?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
</session-factory>
</hibernate-configuration>
There is only 1 entity in this test case -
Employee.java:
import ...
@Audited
public class Employee implements java.io.Serializable {
private Long id;
private String name ;
@NotAudited
private Map customProperties = new HashMap(); // maps to dynamic-component
.. getter/setter ...
Hibernate mapping (using xml as dynamic-component is not available as annotation)
<hibernate-mapping default-access="property">
<class name="com.company.domain.Employee" table="EMPLOYEE">
<id name="id" column="id">
<generator class="native"/>
</id>
<property name="name" type="string" column="name" length="255" not-null="false"/>
<dynamic-component insert="true" name="customProperties" optimistic-lock="true" unique="false" update="true" >
</dynamic-component>
</class>
</hibernate-mapping>
HibernateUtil -
private static SessionFactory buildSessionFactory() {
try {
// Create the SessionFactory from hibernate.cfg.xml
AuditEventListener auditEventListener = new AuditEventListener();
Configuration configuration = new Configuration();
configuration.getEventListeners().setPostInsertEventListeners(new PostInsertEventListener[]{auditEventListener});
configuration.getEventListeners().setPostUpdateEventListeners(new PostUpdateEventListener[]{auditEventListener});
configuration.getEventListeners().setPostDeleteEventListeners(new PostDeleteEventListener[]{auditEventListener});
return configuration.configure().buildSessionFactory();
}
catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
Main class -
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
App app = new App();
app.createAndStore();
app.createAndStoreVersion();
HibernateUtil.getSessionFactory().close();
}
private void createAndStore() {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Employee emp = new Employee();
emp.setName("name");
session.save(emp);
session.getTransaction().commit();
}
private void createAndStoreVersion() {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Employee emp = (Employee) session.get(Employee.class, 1L);
emp.setName("updated name");
session.save(emp);
session.getTransaction().commit();
}
}
Initialization fails, log is:
Caused by: java.lang.NullPointerException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.hibernate.annotations.common.util.ReflectHelper.classForName(ReflectHelper.java:143)
at org.hibernate.annotations.common.reflection.java.JavaReflectionManager.classForName(JavaReflectionManager.java:117)
at org.hibernate.envers.configuration.metadata.reader.AuditedPropertiesReader$ComponentPropertiesSource.<init>(AuditedPropertiesReader.java:269)
at org.hibernate.envers.configuration.metadata.reader.AuditedPropertiesReader$ComponentPropertiesSource.<init>(AuditedPropertiesReader.java:263)
at org.hibernate.envers.configuration.metadata.reader.AuditedPropertiesReader.addFromProperties(AuditedPropertiesReader.java:105)
at org.hibernate.envers.configuration.metadata.reader.AuditedPropertiesReader.addPropertiesFromClass(AuditedPropertiesReader.java:89)
at org.hibernate.envers.configuration.metadata.reader.AuditedPropertiesReader.read(AuditedPropertiesReader.java:67)
at org.hibernate.envers.configuration.metadata.reader.AnnotationsMetadataReader.getAuditData(AnnotationsMetadataReader.java:114)
at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:80)
at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:97)
at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:129)
at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:335)
at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)
... 6 more
After some debugging I found that a dynamic-component doesn't have class attribute (it is always java.util.HashMap), envers tries to look it up and fails.
Secondly, I coudln't figure out how to attach envers listeners via hibernate.cfg.xml, so used run time configuration.
All the three approaches failed -
1. <property name="hibernate.ejb.event.post-insert">org.hibernate.ejb.event.EJB3PostInsertEventListener,org.hibernate.envers.event.AuditEventListener</property>
2. <listener class="org.hibernate.envers.event.AuditEventListener" type="post-insert"/> (DTD validation fails)
3. <event type="post-insert">
<listener class="org.hibernate.envers.event.AuditEventListener"/>
</event> (DTD validation fails).
Also tracked in forum - https://forum.hibernate.org/viewtopic.php?f=1&t=1009975
Junit to reproduce this scenario is attached. Execute App.java, you'll need mysql.
regards,
Rajeev
--
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, 5 months
[Hibernate-JIRA] Created: (HHH-5955) Add support to @OrderColumn JPA2 annotation to work with @AuditMappedBy
by benoit heinrich (JIRA)
Add support to @OrderColumn JPA2 annotation to work with @AuditMappedBy
-----------------------------------------------------------------------
Key: HHH-5955
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5955
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.6.1, 3.6.0
Environment: jboss 6.0.0.Final and hibernate 3.6.0.Final
Reporter: benoit heinrich
Hi guys,
I'm working on a project where we're using envers and since we're migrating from jboss 4.2.3 to jboss 6.0.0.Final (finally), I'm then upgrading the old envers to the new one.
Part of the migration I've changed all the @IndexColumn by the new JPA2 @OrderColumn and it seems that envers doesn't work with that new annotation (or I might do something wrong here )
Also, since we're now using the @OrderColumn the "position" column on the referenced entity has been removed as the hibernate documentation (and JPA2 specs) ask for it. Since it's been removed I'm getting the problem.
Here is the example mapping:
{code}
@Entity
@Audited
public class OrganizationEntity {
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
@JoinColumn(name = "org_entity_id", columnDefinition = "int", nullable = false)
@OrderColumn(name = "position", columnDefinition = "tinyint", nullable = false)
@AuditMappedBy(mappedBy = "organizationEntity", positionMappedBy = "position")
private List contactDetailList;
}
@Entity
@Audited
public class OrganizationEntityContactDetail {
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "org_entity_id", columnDefinition = "int", nullable = false, insertable = false, updatable = false)
private OrganizationEntity organizationEntity;
}
{code}
Every time I deploy this I'm getting the following error:
{code}
Caused by: org.hibernate.HibernateException: could not init listeners
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:205) :3.6.0.Final
at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1980) :3.6.0.Final
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1842) :3.6.0.Final
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:902) :3.6.0.Final
... 73 more
Caused by: org.hibernate.MappingException: @AuditMappedBy points to a property that doesn't exist: com.example.services.organization.entity.OrganizationEntityAddress.position
at org.hibernate.envers.configuration.ClassesAuditingData.forcePropertyInsertable(ClassesAuditingData.java:83)
at org.hibernate.envers.configuration.ClassesAuditingData.updateCalculatedFields(ClassesAuditingData.java:72)
at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:86)
at org.hibernate.envers.configuration.AuditConfiguration.(AuditConfiguration.java:97)
at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:129)
at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:335)
at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198) :3.6.0.Final
at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181) :3.6.0.Final
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194) :3.6.0.Final
... 76 more
{code}
More details can be read there: http://community.jboss.org/message/589031
Thanks for looking at it :)
Cheers,
/Benoit
--
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, 5 months
[Hibernate-JIRA] Created: (EJB-364) Composite PK and @GeneratedValue
by Radosław Smogura (JIRA)
Composite PK and @GeneratedValue
--------------------------------
Key: EJB-364
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-364
Project: Hibernate Entity Manager
Issue Type: Bug
Affects Versions: 3.3.2.GA
Environment: Hibernate 3.2.6
Glassfish
PostgreSQL
Reporter: Radosław Smogura
Priority: Critical
[code]
For class like this
@Entity
@IdClass(FooId.class)
/* Seq / Table generator */
public class Foo {
int id1;
int id2;
@Id
public getId1() {
return id1;
}
public setId1(....);
@Id
@GeneratedValue(strategy=AUTO/IDENTITY/SEQUENCE/TABLE)
public int getId2() {
return id2;
}
public void setId2(.....);
}
[/code]
Id1 is set manully, but id2 is unchanged i this situation hibernate doesn't generates PK and tries to insert NULL causing error.
Specification requires assigning of generated value with @Id properties. Part 2.4.1 defines two types of PKs simple and composite and part 9.1.9 says about PKs in generally. (SEQ or IDENTITY is specification depended, but PostgreSQL support it and Hibernate should support it too).
--
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, 5 months