[Hibernate-JIRA] Commented: (ANN-354) @javax.persistence.SequenceGenerator defaults to 'seqhilo' strategy.
by Andrew Pitt (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-354?page=co... ]
Andrew Pitt commented on ANN-354:
---------------------------------
I agree this is not a bug, but I also agree that the solution is less than ideal.
With so much of hibernate being configurable, I'm surprised the hilo generator would be hard coded in. Adding "allocationSize=1" to your annotations is fine if you have one or two, but a maintenance pain if you have many.
If the hilo generator is going to be forced on developers, it would be nice to at least be able to alter the allocationSize in the config, so that there's only ONE place to maintain this value.
- Andrew
> @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
15 years, 2 months
[Hibernate-JIRA] Created: (HHH-3822) mysql lack of timestamps with milliseconds breaks hibernate when used with versioning
by Thomas Hartwig (JIRA)
mysql lack of timestamps with milliseconds breaks hibernate when used with versioning
-------------------------------------------------------------------------------------
Key: HHH-3822
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3822
Project: Hibernate Core
Issue Type: Improvement
Components: core
Affects Versions: 3.3.1
Environment: mysql-5.1.32-1.fc10
Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
Reporter: Thomas Hartwig
When I persist an instance with saveOrUpdate into a mysql dbms a version field is kept in milliseconds precision in the current application context. Unfortunately mysql truncates all the milliseconds from this field. So a following merge or any other version based operation fails until the object is refetched.
Possible workarounds:
- use an interceptor for truncating the version field
- avoid using timestamp of mysql
I know the milliseconds problem is really annoying by mysql and it is not a hibernate fault, but probably it can be avoided somehow or hibernate should throw an unsupported exception.
Below is the sample setup:
@Entity
@Table(cname = "_Column")
public class MappedColumn implements Serializable {
private Date mtime;
@Version
public Date getMtime() {
return mtime;
}
public void setMtime(Date mtime) {
this.mtime = mtime;
}
[...]
}
CREATE TABLE `_Column` (
`name` varchar(255) collate latin1_german1_ci NOT NULL,
`booleanColumn` bit(1) NOT NULL default '\0',
`id` varchar(255) collate latin1_german1_ci NOT NULL default '',
`ctime` datetime default NULL,
`mtime` datetime default NULL,
`columnOsc` varchar(255) collate latin1_german1_ci default NULL,
`columnDbr` int(11) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_german1_ci;
--
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, 2 months