[jboss-user] [EJB 3.0] - Re: Problem using SequenceGenerator

Arno Werr do-not-reply at jboss.com
Thu Jul 27 07:53:32 EDT 2006


I am using PostgreSQL which utilizes sequence generator.
Declaring id

  |         @Id
  | 	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "hibernate3_sequence")
  | 	private Long id;
  | 
Wiring up sequence generator for all entities in orm.xml

  | <entity-mappings
  | 	xmlns="http://java.sun.com/xml/ns/persistence/orm"
  | 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  | 	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
  | 	version="1.0">
  | 	<sequence-generator
  | 		name="hibernate3_sequence"
  | 		sequence-name="postmaster_sequence" />
  | </entity-mappings>
  | 
Works like a charm.
Have you tried all available options for SequenceGenerator annotation?

  | @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
  | public @interface SequenceGenerator {
  | String name();
  | String sequenceName() default "";
  | int initialValue() default 1;
  | int allocationSize() default 50;
  | }
  | 
Yet, like I said, I am using PostgreSQL 7.4. Your problem could be DB related.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3961261#3961261

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3961261



More information about the jboss-user mailing list