You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Jerry Carter <je...@jerrycarter.org> on 2010/02/26 18:07:26 UTC

OpenJPA 2.0.0-beta issue with sequences and inheritance

Not entirely sure this is a real issue yet, but starting to get quite suspicious....

I have multiple child classes which inherit from a base class using a Joined strategy.  The sequence is defined in the base class and only in the base class.  I am seeing a 'Sequence already exists' message while running the unit tests.  

Anyone else seeing this or successfully using joined inheritance with sequence generators with the 2.0 beta?



[Stack trace]

Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Sequence already exists in statement [CREATE SEQUENCE geoindex_idx_seq START WITH 1] {stmnt 1509237029 CREATE SEQUENCE example_seq START WITH 1} [code=-192, state=S1000]
	at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:254)
	at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700(LoggingConnectionDecorator.java:70)
	at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingStatement.executeUpdate(LoggingConnectionDecorator.java:944)
	at org.apache.openjpa.lib.jdbc.DelegatingStatement.executeUpdate(DelegatingStatement.java:136)
	at org.apache.openjpa.jdbc.schema.SchemaTool.executeSQL(SchemaTool.java:1200)
	at org.apache.openjpa.jdbc.schema.SchemaTool.createSequence(SchemaTool.java:976)
	at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:461)
	at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:348)
	at org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:325)
	at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:504)
	... 40 more

[Class heirarchy]

@Entity
@Table(name="base_table")
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name="reference_type", discriminatorType=DiscriminatorType.INTEGER)
public abstract class BaseClass {
	// IDENTITY RELATED
	@SequenceGenerator(name="Seq_Example_Gen", sequenceName="example_seq") 
	@Id @Column(name="my_index") @GeneratedValue(generator="Seq_Example_Gen", strategy=GenerationType.SEQUENCE)
	private long id;
	public long getId() { return id; }
	public void setId(long id) { this.id = id; }
	
	... et cetera ...
}

@Entity
@Table(name="child_table_one")
@DiscriminatorValue("1")
public class ChildClassOne extends BaseClass implements Serializable {
	... et cetera ...
}

@Entity
@Table(name="child_table_two")
@DiscriminatorValue("2")
public class ChildClassTwo extends BaseClass implements Serializable {
	... et cetera ...
}


Re: OpenJPA 2.0.0-beta issue with sequences and inheritance

Posted by No1UNo <je...@jerrycarter.org>.
Not yet able to reproduce this in a unit test.  I think this can be
disregarded as user error.
-- 
View this message in context: http://n2.nabble.com/OpenJPA-2-0-0-beta-issue-with-sequences-and-inheritance-tp4640449p4682295.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.