[Hibernate-JIRA] Created: (HHH-2197) make more information about the persistent class available to NamingStrategy methods
by Jason Trump (JIRA)
make more information about the persistent class available to NamingStrategy methods
------------------------------------------------------------------------------------
Key: HHH-2197
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2197
Project: Hibernate3
Type: Improvement
Components: core
Versions: 3.2.0.ga
Environment: all environments
Reporter: Jason Trump
Priority: Minor
Currently NamingStrategy.propertyToColumnName() implementations are only passed the bare property name for persistent entities, without any information about which class is being persisted. It would be nice if the persistent classname was also provided, so that information about the class could be used in deciding how to generate the column name.
To give an example, in a client's database, all of the column names begin with an abbreviation of the table name itself:
create table TBL_Foo (
FooUuid tinyint primary key,
FooProperty varchar(32)
)
maps to class:
public class Foo {
private Integer uuid;
private String property;
....
}
Right now propertyToColumnName(String) is only called with the arguments "uuid" or "property", making it impossible to automatically prefix "Foo" with a NamingStrategy. To preserve backwards-compatibility, maybe we could get another version of propertyToColumnName, like
/**
* @param className fully-qualified className of the persistent class, or entity-name for non-pojo persistence
* @param propertyPath property name relative to <code>className</code>
*/
public String propertyToColumnName(String className, String propertyPath);
with similar overloaded versions on other methods in the interface, with the same idea. apologies if this type of thing is already available in the current release, but I didn't find evidence of this either in the forums or by inspecting the code.
thanks for hibernate and Hibernate entitymanager! i've been a fan for several years now.
--
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, 3 months
[Hibernate-JIRA] Commented: (HB-1548) CLONE -Ability to specify names of constraints (PK, Check, Unique)
by Diego Pires Plentz (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HB-1548?page=co... ]
Diego Pires Plentz commented on HB-1548:
----------------------------------------
Dup.
> CLONE -Ability to specify names of constraints (PK, Check, Unique)
> ------------------------------------------------------------------
>
> Key: HB-1548
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HB-1548
> Project: Hibernate2
> Issue Type: Improvement
> Components: core, toolset
> Affects Versions: 2.1.7
> Reporter: Steve Ebersole
> Assignee: Steve Ebersole
> Priority: Minor
>
> Under Oracle, and possibly other DBs, if you dont specify a constraint name for primary keys, check and unique constraints Oracle creates a system default name which is no help to anyone hitting the DB if the violate the constraint.
> It would be nice to be able to generate SQL along the lines of:
> CREATE TABLE foo
> (
> id number(19,0) not null,
> a integer not null,
> b integer not null,
> CONSTRAINT PK_foo PRIMARY KEY (ID),
> CONSTRAINT CK_A_NONZERO CHECK ( a > 0 ),
> CONSTRAINT CK_B_NONZERO CHECK ( b > 0 )
> );
> where the PK name for the <id> element can be set by attribute (similar to how the foreign-key name can be set).
> For check constraints, maybe an additional attribute check-name=""
> could be added
> Ive implemented the PK name for <id> elements, but now notice there are additional PKs created by Hibernate. The check constraint seems a little more involved, but I was thinking about derriving a new class, CheckConstraint from Constraint, and having the value from the existing check attribute stored, and also a constraintName.
> The individual dialects could then have a new getCreateConstraintSQL method to switch this out for the different DBs.
> Nick
--
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, 3 months
[Hibernate-JIRA] Created: (HHH-2869) Atomic remove + add of unique properties to a persistent set fails
by Pietu Pohjalainen (JIRA)
Atomic remove + add of unique properties to a persistent set fails
------------------------------------------------------------------
Key: HHH-2869
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2869
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.5
Environment: Hibernate 3.2.5 (2007.07.31);
Oracle 9
Reporter: Pietu Pohjalainen
Priority: Minor
Attachments: hibernate-unique-showcase.zip
Trying to remove and add equal objects to a persistent set with unique property on, fails.
E.g. we have a set 'set' with one object, "X" contained in it. A sequence of
set.clear();
set.add("X");
session.update(set);
produces a unique constraint exception from the underlying database, because the update first tries to add the newly added objects, and only after that it tries to remove those.
E.g. Oracle produces the following exception: "Caused by: java.sql.BatchUpdateException: ORA-00001: unique constraint (SHOWCASE.SYS_C0036053) violated"
A workaround is would be to run the session.update(set); session.flush(); after clearing the set - but I would argue that interleaving the persistence-code with regular object handling code does not exactly fulfill the promise of 'transparent persistency'.
Please see the attached showcase.zip, which sets up a database. There's a 'container', which contains a set of 'values', where values should be unique across all sets in the system. When trying to remove and add the same value to a set, the program throws an exception.
The showcase driver script is located in class hibernate.Showcase. The object model classes are located in test.Container and test.Value.
--
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, 3 months
[Hibernate-JIRA] Commented: (ANN-354) @javax.persistence.SequenceGenerator defaults to 'seqhilo' strategy.
by Emmanuel Bernard (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-354?page=co... ]
Emmanuel Bernard commented on ANN-354:
--------------------------------------
I already commented on it, use allocationSize=1 and no this is not a bug
> @javax.persistence.SequenceGenerator defaults to 'seqhilo' strategy.
> --------------------------------------------------------------------
>
> Key: ANN-354
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-354
> Project: Hibernate Annotations
> Issue Type: Improvement
> Affects Versions: 3.2.0.cr1
> Reporter: Andrey Petrov
>
> When using an oracle-style sequence to auto generate primary key values like this:
> @Id
> @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="MySeq")
> @SequenceGenerator(name="MySeq", sequenceName="ORACLE_SEQ")
> public long getId() {
> return id;
> }
> then a org.hibernate.id.SequenceHiLoGenerator is always used.
> There should be a way to configure a different generator!
> Since the hilo generator is not suitable for my application I have to use this instead:
> @Id
> @GeneratedValue(generator="MySeq")
> @GenericGenerator(
> //this is a hibernate-specific hack to force the use of a regular sequence generator
> //otherwise a sequencehilo generator is used by default :-(((
> name = "MySeq", strategy = "sequence", parameters = {
> @Parameter(name = "sequence", value = "ORACLE_SEQ")
> }
> )
> public long getId() {
> return id;
> }
> Now this works fine and while this solution can be tolerated for my app I really wish there was another way to control the default generator strategy (sequencehilo or plain sequence) without resorting to hibernate-specific org.hibernate.annotations.GenericGenerator annotations.
> Do you think a mechanism for configuring that can be added to a future hibernate annotations version?
> p.s.
> as long as i can see the seqhilo generation strategy is hardcoded in:
> org.hibernate.cfg.AnnotationBinder.java:1925: case SEQUENCE:
> org.hibernate.cfg.AnnotationBinder.java:1926: return "seqhilo";
> (in hibernate annotations version 3.2.0.cr1)
--
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, 3 months
[Hibernate-JIRA] Commented: (ANN-210) @ManyToOne not working wth @Formula
by Emmanuel Bernard (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-210?page=co... ]
Emmanuel Bernard commented on ANN-210:
--------------------------------------
yes you can mix xml and annotations provided that a given class hierarchy uses the same mechanism
> @ManyToOne not working wth @Formula
> -----------------------------------
>
> Key: ANN-210
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-210
> Project: Hibernate Annotations
> Issue Type: Improvement
> Components: binder
> Affects Versions: 3.1beta7
> Environment: Hibernate 3.1, PostgreSQL 8.1.1
> Reporter: Jason Long
>
> This type of mapping fails:
> @ManyToOne
> @Formula(value="( select v_pipe_offerprice.offerprice_fk from v_pipe_offerprice where v_pipe_offerprice.id = id )")
> public OfferPrice getOfferPrice() { return offerPrice; }
> While the following mapping works as expected:
> <class name="Pipe" table="t_pipe">
> ...
> <many-to-one name="offerPrice"
> class="pipetracker.model.price.OfferPrice"
> formula="( select v_pipe_offerprice.offerprice_fk
> from v_pipe_offerprice
> where v_pipe_offerprice.id = id )"/>
> ...
> </class>
> This is not being treated as a formula because the generated SQL included a referece to the field pipe.offerprice_id which does not exsist because this is a virtual column calculated from a view.
--
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, 3 months
[Hibernate-JIRA] Resolved: (HHH-1018) Duplicate insert in join table when calling session.flush() twice
by Diego Pires Plentz (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1018?page=c... ]
Diego Pires Plentz resolved HHH-1018.
-------------------------------------
Assignee: Diego Pires Plentz
Resolution: Duplicate
> Duplicate insert in join table when calling session.flush() twice
> -----------------------------------------------------------------
>
> Key: HHH-1018
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1018
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1 beta 2
> Environment: MySQL 5.0.13, Hibernate 3.1 beta 3, jdk 1.5.0_05, ant 1.6.2
> Reporter: Connor Barry
> Assignee: Diego Pires Plentz
> Attachments: HibernateJIRA.zip
>
>
> see http://forums.hibernate.org/viewtopic.php?t=948463&sid=a1a88b56a4e3062d54...
> My problem is that when I run the above code, I call flush() twice. The second time I call flush(), it correctly generates an update() statement, but also tries to insert a second identical row in the join table activity_deals, which fails due to a non-unique-key problem.
> Why is Hibernate trying to insert the row twice? I've verified that after the first flush(), Activity and Deal are both persistent and have both been inserted into their respective tables, and join table.
--
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, 3 months
[Hibernate-JIRA] Created: (HHH-2556) HQL queries with many-to-one joins with property-ref fail
by Bill Swayze (JIRA)
HQL queries with many-to-one joins with property-ref fail
----------------------------------------------------------
Key: HHH-2556
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2556
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.1
Environment: 3.2.1 Sybase 12.x
Reporter: Bill Swayze
Priority: Critical
I am experiencing a similar problem to HHH768. In HQL with many-to-one associations using a property-ref, the 'one' end of the association (all requisite fields) is retrieved and partially resolved and saved in entitiesByKey. In subsequent result set processing, an attempt to resolve the entity in entitiesByUniqueKey is unsuccessful as it is trying to use the pk. Ultimately, the entity is null in the results of .list().
Consider the following simple mappings and query:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class name="test.A"
table="a_t">
<id name="id" column="id" type="java.lang.Integer">
<generator class="assigned"/>
</id>
<many-to-one name="child" class="test.B" column="str_id" property-ref="key" not-null="true"/>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class name="test.B"
table="b_t">
<id name="id" column="id" type="java.lang.Integer">
<generator class="assigned"/>
</id>
<property name="data" type="java.lang.String" column="data" not-null="true" length="80" />
<property name="key" type="java.lang.String" column="str_id" unique="true" not-null="true" length="80" />
</class>
</hibernate-mapping>
select aa.id, bb from A aa inner join aa.child bb where aa.id = 1
This query returns all requisite fields along with an additional column that refers to b's pk. This column is used, erroneously, to try to look up the entity by unique key. It is not clear to me whether the problem is in the result set processing or the new query parser.
I was counting on using this functionality to expand our use of Hibernate and ease the transition of significant amounts of legacy tables.
--
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, 3 months