[Hibernate-JIRA] Created: (HHH-3316) If expression support in the criteria API
by Avlesh Singh (JIRA)
If expression support in the criteria API
-----------------------------------------
Key: HHH-3316
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3316
Project: Hibernate3
Issue Type: Improvement
Components: query-criteria
Environment: Hibernate 3, MySQL 4.1
Reporter: Avlesh Singh
Priority: Minor
MySQL supports IF() as one of the Control Flow Structures. I am not too sure if other dialects support an equivalent.
This is how it works -
SELECT IF(1>2,2,3);
-> 3
To the best of my knowledge, there is no implementation in the Restrictions/Expression class for this control structure. Underneath is what I am talking about this implementation in the Expression class
public static org.hibernate.criterion.Criterion ifExpression(org.hibernate.criterion.Criterion criterion, java.lang.Object trueValue, java.lang.Object falseValue){}
for which usage would typically look like this-
Criteria queryCriteria = session.createCriteria(MyBean.class);
queryCriteria.add(Expression.ifExpression(Expression.isNull("myProperty"), "myProperty", new Date()));
the bean definition is underneath -
class MyBean{
private Date myProperty;
}
I would love to hear from others on this.
--
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
17 years, 10 months
[Hibernate-JIRA] Assigned: (HBX-592) hbm2ddl update=true not working
by Anthony Patricio (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-592?page=co... ]
Anthony Patricio reassigned HBX-592:
------------------------------------
Assignee: Anthony Patricio
> hbm2ddl update=true not working
> -------------------------------
>
> Key: HBX-592
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-592
> Project: Hibernate Tools
> Issue Type: Bug
> Affects Versions: 3.1.beta5
> Reporter: Dorel Vaida
> Assignee: Anthony Patricio
>
> The problem that I am encountering is that no matter what I change into the mapping files, the hbm2ddl, update=true will not generate the update statements into the indicated SQL output file, nor export them into the DB.
> The ANT target:
> <target name="update-tables" description="Update tables">
> <tstamp>
> <format property="stamp" pattern="yyyy-MM-dd_hh-mm-ss" />
> </tstamp>
> <hibernatetool destdir="../sql">
> <classpath>
> <!-- a classpath is optional, but needed for exporters that require access to domain classes etc. -->
> <path refid="master-classpath" />
> </classpath>
> <configuration configurationfile="src/hibernate-gen.cfg.xml" />
> <!-- annotated class/packages are specified in the hibernate.cfg.xml -->
> <hbm2ddl update="true" outputfilename="rf-update_${stamp}.sql" />
> <!-- SchemaExport based on Annotations -->
> </hibernatetool>
> </target>
> Hibernate version: 3.1.1
> Tools version: HibernateTools-3.1.0.beta4
--
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
17 years, 10 months
[Hibernate-JIRA] Assigned: (HHH-1186) Write generated sql to a file for SchemaUpdate.
by Anthony Patricio (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1186?page=c... ]
Anthony Patricio reassigned HHH-1186:
-------------------------------------
Assignee: Anthony Patricio
> Write generated sql to a file for SchemaUpdate.
> -----------------------------------------------
>
> Key: HHH-1186
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1186
> Project: Hibernate3
> Issue Type: Improvement
> Components: metamodel
> Affects Versions: 3.1 rc3
> Environment: hibernate 3.1rc3
> mysql
> Reporter: Sjoerd Takken
> Assignee: Anthony Patricio
> Priority: Minor
> Attachments: SchemaUpdate.java, SchemaUpdate.patch, schemaUpdate.patch
>
>
> I would like to export the output from SchemaUpdate to a file. This is implemented for SchemaExport but it is not implemented for SchemaUpdate.
> The reason is that I don't want to execute the output from SchemaUpdate directly. Because I want to change it. For example
> I want to add drop statements for some tables.
> I want to change the generate alter table add column statements to alter table change column in some cases, because the name is changed and I don't want to drop the data of my column.
> Could you add this improvement to Hibernate.
> Can you also change the ant HibernateTool hbm2ddl
> You can set an outputfilename for the case update=false and it runs SchemaExport.
> But if it runs SchemaUpdate ( update=true ), then outputfilename is not used.
> I would like to use this property for the improvement.
--
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
17 years, 10 months
[Hibernate-JIRA] Created: (HHH-3315) Criteria API to accept SQL strings in the orderBy clause
by Avlesh Singh (JIRA)
Criteria API to accept SQL strings in the orderBy clause
--------------------------------------------------------
Key: HHH-3315
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3315
Project: Hibernate3
Issue Type: Improvement
Components: query-criteria
Environment: Hibernate3, MySQL 4.1
Reporter: Avlesh Singh
Priority: Minor
The criteria interface accepts an "Order" in the addOrder method to sort the resultset. This is how it currently works:
Criteria queryCriteria = session.createCriteria(MyBean.class);
queryCriteria.addOrder(Order.asc("myBeanProperty"));
In my specific case, I needed a sql expression instead of a property name. The Order class had no specific method (unlike the Expression class) to use a sql string instead of the "property" itself. I would have loved to see a
public static org.hibernate.criterion.Order sql(java.lang.String sqlString){}
implementation in the Order class.
Alternatively, The Criteria interface can have this method -
org.hibernate.Criteria addOrder(java.lang.String sqlString);
I feel its a nice to have feature.
--
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
17 years, 10 months
[Hibernate-JIRA] Commented: (HHH-1661) merge of a deleted object results in a insert?
by Emmanuel Bernard (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1661?page=c... ]
Emmanuel Bernard commented on HHH-1661:
---------------------------------------
Arthur Brown wrote:
ou argued that one ist don't know for *shure* that the state of "deleted" an entity realy "detached" is.
But it's definitly the case. I cannot understand why this bug is stil opened.
I took a look and debugged the stuff, an I have only to replace 2 lines of code (that was alread there), and voula, this behaive exactly as it schould.
Please could you consider this pacth and try to close this bug?
Old version
if (result == null) {
// TODO: we should throw an exception if we really *know* for sure
// that this is a detached instance, rather than just assuming
// throw new StaleObjectStateException(entityName, id);
// we got here because we assumed that an instance
// with an assigned id was detached, when it was
// really persistent
entityIsTransient(event, copyCache);
}
New version
if (result == null) {
// TODO: we should throw an exception if we really *know* for sure
// that this is a detached instance, rather than just assuming
throw new StaleObjectStateException(entityName, id);
// we got here because we assumed that an instance
// with an assigned id was detached, when it was
// really persistent
// entityIsTransient(event, copyCache);
}
For now, one could derive his own MergeListener from the dafualt one,
replace these lines and repalce the MergeListener in EventListsners.
I tested this, and it seems ok for me.
Regards
Arthur Brown
> merge of a deleted object results in a insert?
> ----------------------------------------------
>
> Key: HHH-1661
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1661
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1.3
> Environment: Hibernate 3.1.3, SQL Server
> Reporter: Tu-Thach
>
> A persistent object is loaded from a session and deleted, then close the session. Using that same object in another session and call merge results in the object being inserted into the database. Here's the sample code:
> Session session = factory.getCurrentSession();
> session.beginTransaction();
> MyClass obj = (MyClass)session.load(MyClass.class, new Integer(10));
> session.delete(obj);
> session.getTransaction().commit();
> session = factory.getCurrentSession();
> session.beginTransaction();
> session.merge(obj);
> session.getTransaction().commit();
> Since the object is already deleted, merge could not find it and thus proceeds with a INSERT. Shouldn't it throw an exception instead?
--
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
17 years, 10 months