[Hibernate-JIRA] Created: (HHH-6580) Discriminator value used as ID when inserting entity to PosgtreSQL
by Paweł Stawicki (JIRA)
Discriminator value used as ID when inserting entity to PosgtreSQL
------------------------------------------------------------------
Key: HHH-6580
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6580
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.6, 3.6.5, 3.6.4, 3.6.3, 3.6.2, 3.6.1, 3.6.0
Environment: Tested on Hibernate 3.6.0, but I looked in the code of 3.6.6 and 4.0.0 Beta4 and it looks like it isn't fixed.
PostgreSQL 8.4.8
Reporter: Paweł Stawicki
When we have inheritance strategy SINGLE_TABLE, and we use discriminator column, this column is the first one in table. Now we want to insert some entity inheriting from this one, and we want PostgreSQL to automatically generate the ID for the new entity. Discriminator column is the first in the table.
Hibernate runs IdentityGenerator.GetGeneratedKeysDelegate.executeAndExtract(), which gets ResultSet from PreparedStatement (in Hibernate 3.6.0 it's line 97 in IdentityGenerator).
This ResultSet, in case of PostgreSQL, contains whole inserted row, not only ID. This is the problem if ID is not the first column, because then Hibernate get's value from the first column and uses it as ID. It's in IdentifierGeneratorHelper.getGeneratedIdentity() and IdentifierGeneratorHelper.get().
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
11 years, 12 months
[Hibernate-JIRA] Created: (HHH-7099) Unable to build EntityManagerFactory with not-JTA Datasource
by Wilson Horstmeyer Bogado (JIRA)
Unable to build EntityManagerFactory with not-JTA Datasource
------------------------------------------------------------
Key: HHH-7099
URL: https://hibernate.onjira.com/browse/HHH-7099
Project: Hibernate ORM
Issue Type: Bug
Components: entity-manager
Affects Versions: 4.1.0, 4.0.1
Environment: Tomcat 7, Java 7, Hibernate 4.x, Servlet 3.0
Reporter: Wilson Horstmeyer Bogado
Attachments: HibernateTest.zip
When upgrading from Hibernate 3.6.x to Hibernate 4.x it is not possible to create an entity manager factory using a non-JTA Datasource in persistence.xml. When looking up the datasource with JNDI a "javax.naming.NamingException: This context must be accessed through a java: URL" exception is thrown. Debugging the source code we can see that in 3.6.x the lookup is done with "javax.naming.lookup(String)" but in 4.x it is done with "javax.naming.lookup(Name)" which fails.
The attached file is a test case. To reproduce, do the following:
1. Build the project with Maven
2. Deploy to Tomcat
3. Go to /hibernate-test/test
Result: All database records are shown in browser
Now, in pom.xml file, change hibernate.core.version property from 3.6.10.Final to 4.1.0.Final.
Repeat above steps.
Result: an exception stack trace is displayed which ends with:
Caused by: javax.naming.NamingException: This context must be accessed through a java: URL
at org.apache.naming.SelectorContext.parseName(SelectorContext.java:776)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:135)
at javax.naming.InitialContext.lookup(InitialContext.java:415)
at org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:65)
... 42 more
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
11 years, 12 months
[Hibernate-JIRA] Created: (HHH-2847) THIS_"."NAME": invalid identifier when using createCriteria with addOrder
by Ashish Tiwari (JIRA)
THIS_"."NAME": invalid identifier when using createCriteria with addOrder
-------------------------------------------------------------------------
Key: HHH-2847
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2847
Project: Hibernate3
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.0.5
Environment: Oracle - 10.2.0
Reporter: Ashish Tiwari
We are using hibernate 3.0.5 and once a while I see following error getting generated due to incorrect SQL generated by hibernate:
Hibernate: select systembean0_.SYSTEMID as SYSTEMID12_0_, systembean0_.Version as Version12_0_, systembean0_.NAME as NAME12_0_, systembean0_.TYPE as TYPE12_0_, systembean0_.DESCRIPTION as DESCRIPT5_12_0_ from SDSYSTEM systembean0_ order by this_.NAME asc
- SQL Error: 904, SQLState: 42000
- ORA-00904: "THIS_"."NAME": invalid identifier
This normally works but occasionally we run into the issue mentioned above. I do not see alias "this_" in the sql query and I think that causes the error to happen. Issue is caused by alias not used consistently.
In normal case the generated SQL looks like following:
Hibernate: select this_.SYSTEMID as SYSTEMID7_0_, this_.Version as Version7_0_, this_.NAME as NAME7_0_, this_.TYPE as TYPE7_0_, this_.DESCRIPTION as DESCRIPT5_7_0_ from SDSYSTEM this_ order by this_.NAME asc
I am not sure what causes this problem. Has anyone else see similar problem earlier?
I appreciate any help with this. Below is other information:
Hibernate version: 3.0.5
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
name="com.avaya.coreservice.admin.toolkit.common.system.SystemBean"
table="SDSYSTEM">
<id name="uniqueId" type="java.lang.String">
<column name="SYSTEMID" length="50" not-null="true"/>
<generator class="uuid"/>
</id>
<version name="version" column="Version" />
<property
name="name"
type="java.lang.String">
<column name="NAME" length="512" not-null="true"/>
</property>
<property
name="type"
type="java.lang.String">
<column name="TYPE" length="50" not-null="false"/>
</property>
<property
name="description"
type="java.lang.String">
<column name="DESCRIPTION" length="1024" not-null="false"/>
</property>
<set name="resourceBeanSet">
<key>
<column name="SYSTEMID" length="50" not-null="false"/>
</key>
<one-to-many class="com.avaya.coreservice.admin.toolkit.common.resource.ResourceBean"/>
</set>
<set name="siteBeanSet" order-by="name asc">
<key>
<column name="SYSTEMID" length="50" not-null="false"/>
</key>
<one-to-many class="com.avaya.coreservice.admin.toolkit.common.site.SiteBean"/>
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
HibernateUtil.getSession().createCriteria(SystemBean.class)
.addOrder(Order.asc("name")).list();
Full stack trace of any exception that occurs:
N/A
Name and version of the database you are using:
Oracle - 10.2.0
The generated SQL (show_sql=true):
select systembean0_.SYSTEMID as SYSTEMID12_0_, systembean0_.Version as Version12_0_, systembean0_.NAME as NAME12_0_, systembean0_.TYPE as TYPE12_0_, systembean0_.DESCRIPTION as DESCRIPT5_12_0_ from SDSYSTEM systembean0_ order by this_.NAME asc
I appreciate any help with this.
Thanks,
--
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
12 years
[Hibernate-JIRA] Created: (HHH-6215) final fields can't be set if they're public
by Bogdan Butnaru (JIRA)
final fields can't be set if they're public
-------------------------------------------
Key: HHH-6215
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6215
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.4
Environment: Hibernate 3.6.4
Reporter: Bogdan Butnaru
As far as I can tell, Hibernate 3.6.4 can set a {{final}} field, _except_ if both the field and the class it belongs to are declared {{public}}. In other words,
{noformat}
public class Test{
@Column(name = "field")
private final String field = null;
}
{noformat}
will work, as will making the class non-{{public}} and the field {{public}}, but
{noformat}
public class Test{
@Column(name = "field")
public final String field = null;
}
{noformat}
will not. The latter causes an {{org.hibernate.PropertyAccessException}} to be thrown when a {{Test}} object is initialized from the database (caused by a {{java.lang.IllegalAccessException}}).
(The message I get is _"could not set a field value by reflection setter of one.of.my.Classes.field at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:151)"_)
I looked a bit around the sources for 3.6.4 (which I downloaded earlier today) and did a little debugging, and as far as I can tell the problem is in {{DirectPropertyAccessor.getField(Class, String)}}; Specifically, line 176 reads
{noformat}
if ( !ReflectHelper.isPublic(clazz, field) ) field.setAccessible(true);
{noformat}
that is, {{setAccessible}} is not called for {{public}} fields even if they are {{final}}. I don't know the code enough to be sure, but I believe the test should check for {{final}} too.
There is an identical line in the next method (same name but with two {{Class}} arguments, line 191); I suspect that causes the same problem, but I didn't hit that code in my case (AFAIK because I don't have inherited fields).
I'm sorry for not uploading a test case, I don't quite get how to check this, but I hope I pointed close enough to the problem.
--
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
12 years