[Hibernate-JIRA] Created: (HHH-3721) MySql creates multiple indicies when "unique" specified on both column specification and constraint
by Hugh Daschbach (JIRA)
MySql creates multiple indicies when "unique" specified on both column specification and constraint
---------------------------------------------------------------------------------------------------
Key: HHH-3721
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3721
Project: Hibernate Core
Issue Type: Improvement
Components: core
Affects Versions: 3.2.0.ga
Environment: MySql 5.0, hibernate-3.2 compiled from SVN revision 12635.
Reporter: Hugh Daschbach
Priority: Minor
Attachments: hibernate-3.2.patch
MySql seems to duplicate indexes when "unique" is specified both on the column specification as a constraint.
For example:
create table groups (
id int unsigned not null unique auto_increment,
groupname varchar(30) unique not null,
primary key (id),
unique (groupname)
) engine = InnoDB;
show index from groups;
+--------+------------+-------------+--------------+-------------+- ...
| Table | Non_unique | Key_name | Seq_in_index | Column_name |
+--------+------------+-------------+--------------+-------------+- ...
| groups | 0 | PRIMARY | 1 | id | ...
| groups | 0 | id | 1 | id | ...
| groups | 0 | groupname | 1 | groupname | ...
| groups | 0 | groupname_2 | 1 | groupname | ...
+--------+------------+-------------+--------------+-------------+- ...
Note four indexes instead of two.
The attached patch suppresses the "unique" qualifier on the column specification emitted by hbm2ddl. It may be better to apply this to MySqlDialect instead of MySqlInnoDBDialect. Or I may be mistaken altogether.
--
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
15 years, 11 months
[Hibernate-JIRA] Created: (HHH-3717) SINGLE_TABLE inheritance: PersistentCollectionChangeWorkUnit.java: string truncating is used to find a property name from a collectionEntry
by Michele Comitini (JIRA)
SINGLE_TABLE inheritance: PersistentCollectionChangeWorkUnit.java: string truncating is used to find a property name from a collectionEntry
-------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-3717
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3717
Project: Hibernate Core
Issue Type: Bug
Environment: envers 1.1.0 GA
Reporter: Michele Comitini
in PersistentCollectionChangeWorkUnit.java string truncating is used to find a property name from a collectionEntry. It seems that if the entity is derived
with SINGLE_TABLE inheritance this truncating is fault prone.
I attached a quick patch that seems to fix the problem, but I think manipulating strings is still not too safe to find the correct property name...
Here is an excerpt of code that happens to fail:
@Entity
@Versioned
@Table(name = "notifica")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE )
@NamedQueries({
@NamedQuery(name="Notifica.all", query="from Notifica"),
})
public class Notifica extends BaseCQOPEntity implements Persistent
{
private static final long serialVersionUID = -7096378249035298397L;
@Id
@GeneratedValue
@XStreamAlias("idd")
private Long id;
@Where(clause="not(deleted=(1=1))")
@OneToMany(fetch=FetchType.EAGER)
@Cascade({})
private Set<Ruolo> ruoli = new HashSet<Ruolo>();
.
.
.
}
@Entity
@Versioned
@DiscriminatorValue(value="Pratica")
public class NotificaPratica extends NotificaImpresa
{
private static final long serialVersionUID = 1L;
.
.
.
}
--
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
15 years, 11 months
[Hibernate-JIRA] Created: (HHH-3715) NPE in HqlSqlWalker, if named parameter contains a "."
by Andreas Sahlbach (JIRA)
NPE in HqlSqlWalker, if named parameter contains a "."
------------------------------------------------------
Key: HHH-3715
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3715
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.3.1
Reporter: Andreas Sahlbach
Priority: Minor
Query used:
select company from example.PersistentCompany as company join company.attributes as attr where attr.value like :id.krias
With this query I got a NullPointerException in HqlSqlWalker (see Stacktrace below). After some debugging I changed my query to
select company from example.PersistentCompany as company join company.attributes as attr where attr.value like :krias
which works perfectly. I guess the parser misinterpretes the "." in the parametername as tries to resolve a "krias" property. The NPE
occurs, because there is no "next sibling" for the "krias" node.
I suggest to harden your code against such a parameter name. Error would be ok, if "." in parameter names are not allowed, but there should be no NPE which gives no real hint about the cause.
Stacktrace:
at org.hibernate.hql.ast.HqlSqlWalker.lookupProperty(HqlSqlWalker.java:466)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.addrExpr(HqlSqlBaseWalker.java:4.326)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1.212)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3.672)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1.762)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:251)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:134)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1.650)
[...my classes from here 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
15 years, 11 months
[Hibernate-JIRA] Commented: (HHH-1039) WrongClassException when scrolling through EntityMode.DOM4J and loading identical objects from different fields
by Karina Hesse (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1039?page=c... ]
Karina Hesse commented on HHH-1039:
-----------------------------------
If you anytimes get the WrongClassException use the embed-xml="true"/"false" option in the mapping files.
> WrongClassException when scrolling through EntityMode.DOM4J and loading identical objects from different fields
> ---------------------------------------------------------------------------------------------------------------
>
> Key: HHH-1039
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1039
> Project: Hibernate Core
> Issue Type: Bug
> Affects Versions: 3.0.5
> Environment: Windows XP, JDK 1.4.2_8, Hibernate 3.0.5, Oracle 9.2. Replicated on Windows XP, JDK 1.5.0_2, Hibernate 3.0.5, MySQL
> Reporter: Roland Groen
> Fix For: entity-modes
>
> Attachments: HbmXmlTest.java, Loader.java, Test.hbm.xml
>
>
> When working with XML representations of entities, an unexpected org.hibernate.WrongClassException is thrown when working with identical embedded objects (embed-xml="true") which have different field names.
> org.hibernate.WrongClassException seems to be thrown when:
> 1) Running in EntityMode.DOM4J
> 2) Scrolling through a result set using session.scroll()
> 3) Embedding objects that are:
> a) Referred by least by one of the objects on which the query is selecting primarily (parent object) and,
> b) that field is in FetchMode.JOIN.
> c) Referred by one object which is embedded (embed-xml="true") and uses a different field name to refer to the object than the parent object.
> I would like to apologise for the large test case. The bug is quite hard to reproduce, I tried to minimise the test, but this seems the smallest and most simple case I can find.
> The stack trace is:
> Caused by: org.hibernate.WrongClassException: Object with id: 1 was not of the specified subclass: Customer (loaded object was of wrong class)
> at org.hibernate.loader.Loader.instanceAlreadyLoaded(Loader.java:890)
> at org.hibernate.loader.Loader.getRow(Loader.java:846)
> at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:305)
> at org.hibernate.loader.Loader.loadSingleRow(Loader.java:238)
> at org.hibernate.impl.ScrollableResultsImpl.prepareCurrentRow(ScrollableResultsImpl.java:477)
> at org.hibernate.impl.ScrollableResultsImpl.next(ScrollableResultsImpl.java:106)
> at HbxXmlTest.main(HbxXmlTest.java:90)
> The included files are:
> Test.hbm.xml : the hbm file to create the classes
> HbmXmlTest.java : the the java source to reproduce the issue.
> Greetings,
> Roland.
--
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
15 years, 11 months
[Hibernate-JIRA] Created: (HHH-3481) JTATransactionFactory bug when Transaction cannot be found in JNDI
by Steve Ebersole (JIRA)
JTATransactionFactory bug when Transaction cannot be found in JNDI
------------------------------------------------------------------
Key: HHH-3481
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3481
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.0.CR2
Reporter: Steve Ebersole
Assignee: Steve Ebersole
Fix For: 3.2.x, 3.3.x, 3.4
This is the code after linked patch:
protected UserTransaction getUserTransaction() {
log.trace( "Attempting to locate UserTransaction via JNDI [{}]", getUserTransactionName() );
try {
UserTransaction ut = ( UserTransaction ) getInitialContext().lookup( getUserTransactionName() );
if ( ut == null ) {
throw new TransactionException( "Naming service lookup for UserTransaction returned null [" + getUserTransactionName() +"]" );
}
log.trace( "Obtained UserTransaction" );
return ut;
}
catch ( NamingException ne ) {
throw new TransactionException( "Could not find UserTransaction in JNDI [" + getUserTransaction() + "]", ne );
}
}
Notice that in catch of NamingException we try to build a TransactionException. It is supposed to embed the JNDI namespace where we attempted to resolve the Transaction; but rather than getUserTransactionName() we are instead calling back into this same exact method getUserTransaction().
--
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
15 years, 11 months