[Hibernate-JIRA] Created: (JPA-25) Hibernate EntityManager does not allow changing database connection information after EntityManagerFactory creation
by Monique Louise de Barros Monteiro (JIRA)
Hibernate EntityManager does not allow changing database connection information after EntityManagerFactory creation
-------------------------------------------------------------------------------------------------------------------
Key: JPA-25
URL: http://opensource.atlassian.com/projects/hibernate/browse/JPA-25
Project: Java Persistence API
Issue Type: Bug
Affects Versions: 1.0.0
Environment: hibernate-entity-manager-3.2.1.ga, hibernate-3.2.4.sp1, Oracle database
Reporter: Monique Louise de Barros Monteiro
I'm trying to migrate my applications from pure Hibernate to JPA.
In my environment, I have a shared library which creates a SessionFactory at startup. Several Web applications use this library and its shared SessionFactory. Also, each Web application uses a particular datasource with a different user/password, although all the applications access the same database. Upon a request, a Session is obtained from a JDBC connection, which is obtained from the application server's managed pool, referenced by the Web application specific JNDI bound datasource.
When I try to migrate this cenary to JPA, in the same way, I need to create an EntityManagerFactory at startup and let each Web application request create a new EntityManager from the same factory but with different database connection information. But I had the following problems:
- When the EntityManagerFactory is created with a default connection information and the EntityManager is created through EntityManagerFactory.createEntityManager(map), where map contains a JNDI datasource bound to the "javax.persistence.nonJtaDataSource" property, the same EntityManagerFactory connection information is used, and the datasource connection information is completely ignored.
- When the EntityManagerFactory is created without any initial connection information, the following error occurs when an EntityManager is created with datasource information and the underlying JDBC connection needs to accessed:
java.lang.UnsupportedOperationException: The user must supply a JDBC connection
at org.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:30)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
at org.hibernate.jdbc.BorrowedConnectionProxy.invoke(BorrowedConnectionProxy.java:50)
at $Proxy116.prepareStatement(Unknown Source)
I studyied Hibernate's source code and I'm afraid Hibernate does not allow changing connection information (user, password, datasource, etc.) after EntityManagerFactory creation.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years
[Hibernate-JIRA] Created: (HV-530) Explain propagation of redefined default groups across associated instances annotated with @Valid
by Hardy Ferentschik (JIRA)
Explain propagation of redefined default groups across associated instances annotated with @Valid
-------------------------------------------------------------------------------------------------
Key: HV-530
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-530
Project: Hibernate Validator
Issue Type: Task
Components: documentation
Affects Versions: 4.2.0.Final
Reporter: Hardy Ferentschik
Fix For: 4.3.0.next
The examples about default group sequencing do not mention that the default sequence only apply for constraints of the class or superclass. To associated entities only the group Default will be propagated. The spec says:
{quote}
@Valid is an orthogonal concept to the notion of group. If two groups are in sequence, the first group must pass for
all associated objects before the second group is evaluated. Note however that the Default group sequence overriding
is local to the class it is defined on and is not propagated to the associated objects. The following example illustrates
this
{quote}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years
[Hibernate-JIRA] Created: (HHH-6886) Apply {h-schema} place holder in <database-object> SQL
by Cliff Evans (JIRA)
Apply {h-schema} place holder in <database-object> SQL
------------------------------------------------------
Key: HHH-6886
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6886
Project: Hibernate Core
Issue Type: Improvement
Reporter: Cliff Evans
It is currently possible to embed {h-schema} in sql defined in <sql-query> tags and have the place holder be replaced by the value of the default_schema property. It would make sense to have exactly the same behaviour for <database-object> create & drop clauses.
A use case for this is creating an index on a table that's in the schema (using H2 in my case) defined by default_schema. I currently have to hardcode the schema name into the create & drop statements which will obviously break if the default_schema property is changed.
e.g.
<database-object>
<create>
create unique index ak1_indexname on {h-schema}tablename(field1, field2)
</create>
<drop>
drop index ak1_indexname
</drop>
</database-object>
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years
[Hibernate-JIRA] Created: (HHH-5902) In Oracle Dialect Paging query always contains "rownum" pseudo-column when the first result > 0
by Andremoniy (JIRA)
In Oracle Dialect Paging query always contains "rownum" pseudo-column when the first result > 0
-----------------------------------------------------------------------------------------------
Key: HHH-5902
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5902
Project: Hibernate Core
Issue Type: Bug
Components: core, query-sql
Affects Versions: 3.3.2
Environment: Java 1.5, Java 1.6...
Reporter: Andremoniy
Priority: Critical
The issue is about paging query.
For example, we have simple SQL Query: "SELECT p.ID FROM SomeTable p ORDER BY p.ID".
SQLQuery testQuery = HibernateUtil.currentSession().createSQLQuery("SELECT p.ID FROM SomeTable p ORDER BY p.ID");
When we set:
testQuery.setFirstResult(0);
testQuery.setMaxResults(10);
List objs = testQuery.list();
"objs" will contain 10 simple objects of String type (for example).
But, when se set:
testQuery.setFirstResult(10); // here, any value > 0
testQuery.setMaxResults(10);
List objs = testQuery.list();
we will receive list of Object[2] objects:
ID ROWNUM
3212 11
5212 12
5435 13
...
It is absolutely clear, that the core of the problem is in this construction:
Oracle9iDialect.class,
public String getLimitString(String sql, boolean hasOffset) {
...
if (hasOffset) {
pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
}
The resulting query will be:
select * from ( select row_.*, rownum rownum_ from ( SELECT p.ID FROM SomeTable p ORDER BY p.ID ) row_ where rownum <=20) where rownum_ > 10
Why this is a bug?
1. Because I don't want to check: if my query will return simple Object types or Object[] depends on "First Result value".
2. Because I don't need to have second pseudo-column with "rownum" value. It must be optional parameter.
Simple solution for this example could be (see on >>> ID <<<):
select >>> ID <<< from ( select row_.*, rownum rownum_ from ( SELECT p.ID FROM SomeTable p ORDER BY p.ID ) row_ where rownum <=20) where rownum_ > 10
But, of course, in this case this first part of "select" query must be retranslated from inner source query (so, it will be not "SELECT p.ID..." but "SELECT ID" and so on).
--
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-6884) Attribute resultClass doesn't work with NamedNativeQuery
by Tomasz Przybyła (JIRA)
Attribute resultClass doesn't work with NamedNativeQuery
--------------------------------------------------------
Key: HHH-6884
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6884
Project: Hibernate Core
Issue Type: Bug
Components: query-sql
Affects Versions: 3.6.6
Environment: Hibernate 3.6.6.Final over JPA 2.0
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
Reporter: Tomasz Przybyła
Attribute resultClass is set to Long.class, but query returns a list of BigDecimal objects. Below you can see definition of NamedNativeQuery:
{code}
@NamedNativeQueries(
@NamedNativeQuery(name = "getUserGroupsIds",
query = "select id from identities_hierarchy connect by prior id = childid start with childid = ?",
resultSetMapping = "groupIdMapping", resultClass = Long.class
)
)
@SqlResultSetMapping(name = "groupIdMapping",
columns = @ColumnResult(name = "id")
)
{code}
Following code executes this query:
{code}
List<Long> result = getEntityManager().createNamedQuery("getUserGroupsIds", Long.class)
.setParameter(1, userId)
.getResultList();
System.out.println("Returned object is of type: " + ((Iterator<?>) result.iterator()).next().getClass());
{code}
The id column in database is of type NUMBER(10, 0). There are no problems with CriteriaQueries and HQL. Any suggestion how to solve this problem will be greatly welcomed :]
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years