Hi again,
I am back to trying to resolve my original issues, before being sidetracked
with the abstract class problem. I've not yet got a simple test case for
this, but will create one if no-one can give me a solution strait off.
It seems as if foreign keys are being created twice. The stack trace is
below.
I have 4 tables now two abstract and two concrete, one abstract class
extends the other and the two concrete classes extend the second abstract
ctype.
These are:
@PersistenceCapable()
@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, column="class")
public abstract class AbstractChatsDomainEntity {...}
@PersistenceCapable(table="activity")
@Inheritance(strategy = InheritanceStrategy.NEW_TABLE)
@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, column="class")
public abstract class AbstractActivity extends AbstractChatsDomainEntity
implements Activity, Comparable<Activity> {...}
@PersistenceCapable()
@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE)
@DomainObject(objectType = "ACTIVITY")
@DomainObjectLayout(bookmarking = BookmarkPolicy.AS_ROOT)
public class ActivityEvent extends AbstractActivity implements
CalendarEventable {...}
@PersistenceCapable()
@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE)
@DomainObject(objectType = "RECURRING_ACTIVITY")
@DomainObjectLayout(bookmarking = BookmarkPolicy.AS_ROOT)
public class RecurringActivity extends AbstractActivity {...}
I'll remove one of these concrete classes temporarily and see what happens.
21:17:28,766 [Datastore 421163163@qtp-899376395-0 ERROR] An
exception was thrown while adding/validating class(es) : a FOREIGN KEY
constraint already exists on the set of columns: "activity_FK7" in
statement [ALTER TABLE "activity" ADD CONSTRAINT "activity_FK7" FOREIGN KEY
("provider_id_OID") REFERENCES "Provider" ("id") ]
java.sql.SQLSyntaxErrorException: a FOREIGN KEY constraint already exists
on the set of columns: "activity_FK7" in statement [ALTER TABLE "activity"
ADD CONSTRAINT "activity_FK7" FOREIGN KEY ("provider_id_OID") REFERENCES
"Provider" ("id") ]
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source)
at org.hsqldb.jdbc.JDBCStatement.execute(Unknown Source)
at
org.datanucleus.store.rdbms.datasource.dbcp.DelegatingStatement.execute(DelegatingStatement.java:246)
at
org.datanucleus.store.rdbms.datasource.dbcp.DelegatingStatement.execute(DelegatingStatement.java:246)
at
org.datanucleus.store.rdbms.table.AbstractTable.executeDdlStatement(AbstractTable.java:879)
at
org.datanucleus.store.rdbms.table.TableImpl.createForeignKeys(TableImpl.java:522)
at
org.datanucleus.store.rdbms.table.TableImpl.createConstraints(TableImpl.java:426)
at
org.datanucleus.store.rdbms.RDBMSStoreManager$ClassAdder.performTablesValidation(RDBMSStoreManager.java:3443)
at
org.datanucleus.store.rdbms.RDBMSStoreManager$ClassAdder.run(RDBMSStoreManager.java:2880)
at
org.datanucleus.store.rdbms.AbstractSchemaTransaction.execute(AbstractSchemaTransaction.java:119)
at
org.datanucleus.store.rdbms.RDBMSStoreManager.manageClasses(RDBMSStoreManager.java:1612)
at
org.datanucleus.store.rdbms.RDBMSStoreManager.getDatastoreClass(RDBMSStoreManager.java:675)
at
org.datanucleus.store.rdbms.RDBMSPersistenceHandler.getDatastoreClass(RDBMSPersistenceHandler.java:88)
at
org.datanucleus.store.rdbms.RDBMSPersistenceHandler.insertObject(RDBMSPersistenceHandler.java:123)
at
org.datanucleus.state.StateManagerImpl.internalMakePersistent(StateManagerImpl.java:3363)
at
org.datanucleus.state.StateManagerImpl.makePersistent(StateManagerImpl.java:3339)
at
org.datanucleus.ExecutionContextImpl.persistObjectInternal(ExecutionContextImpl.java:2066)
at
org.datanucleus.ExecutionContextImpl.persistObjectWork(ExecutionContextImpl.java:1909)
at
org.datanucleus.ExecutionContextImpl.persistObject(ExecutionContextImpl.java:1764)
at
org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:720)
at
org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:745)
at
org.apache.isis.objectstore.jdo.datanucleus.persistence.commands.DataNucleusCreateObjectCommand.execute(DataNucleusCreateObjectCommand.java:54)
at
org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.executeCommands(DataNucleusObjectStore.java:365)
at
org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.execute(DataNucleusObjectStore.java:359)
at
org.apache.isis.core.runtime.system.transaction.IsisTransaction.doFlush(IsisTransaction.java:527)
at
org.apache.isis.core.runtime.system.transaction.IsisTransaction.flush(IsisTransaction.java:473)
at
org.apache.isis.core.runtime.system.transaction.IsisTransactionManager.flushTransaction(IsisTransactionManager.java:392)
at
org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.executeActionOnTargetAndProcessResults(ActionPanel.java:249)
at
org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.executeActionAndProcessResults(ActionPanel.java:193)
at
org.apache.isis.viewer.wicket.ui.components.actions.ActionParametersFormPanel$ActionParameterForm$1.onSubmit(ActionParametersFormPanel.java:145)
at
org.apache.wicket.ajax.markup.html.form.AjaxButton$1.onSubmit(AjaxButton.java:108)
at
org.apache.wicket.ajax.form.AjaxFormSubmitBehavior$1.onSubmit(AjaxFormSubmitBehavior.java:182)
at
org.apache.wicket.markup.html.form.Form.delegateSubmit(Form.java:1266)
at org.apache.wicket.markup.html.form.Form.process(Form.java:938)
at
org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:770)
at
org.apache.wicket.ajax.form.AjaxFormSubmitBehavior.onEvent(AjaxFormSubmitBehavior.java:159)
at
org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:124)
at
org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:633)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at
org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:258)
at
org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:241)
at
org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:250)
at
org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:236)
at
org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:862)
at
org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
at
org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)
at
org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)
at
org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)
at
org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)
at
org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201)
at
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at
org.apache.isis.core.webapp.diagnostics.IsisLogOnExceptionFilter.doFilter(IsisLogOnExceptionFilter.java:52)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at
org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at
org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at
org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at
org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at
org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
at
org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at
org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: org.hsqldb.HsqlException: a FOREIGN KEY constraint already
exists on the set of columns: "activity_FK7"
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.TableWorks.checkCreateForeignKey(Unknown Source)
at org.hsqldb.TableWorks.addForeignKey(Unknown Source)
at org.hsqldb.StatementSchema.getResult(Unknown Source)
at org.hsqldb.StatementSchema.execute(Unknown Source)
at org.hsqldb.Session.executeCompiledStatement(Unknown Source)
at org.hsqldb.Session.executeDirectStatement(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
... 81 more
On Wed, Sep 2, 2015 at 9:24 AM, Stephen Cameron <[email protected]>
wrote:
>
> Hi
>
> Your solution ends up doing what mine does at the database schema level.
>
> If Datanucleus supports it then shouldn't it be mostly be fine in Isis? If
> not then Isis should warn.
>
> I appreciate your help.
>
>
>
>
> On Wed, Sep 2, 2015 at 4:58 AM, Jeroen van der Wal <[email protected]>
> wrote:
>
>> I've never used @PrimaryKey in an Isis application, don't know if that
>> works. My abstract class would typically look like this:
>>
>> @PersistenceCapable(identityType = IdentityType.DATASTORE)
>> @DatastoreIdentity(column = "id", strategy = IdGeneratorStrategy.IDENTITY)
>> @Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
>> public abstract class AbstractParentType {
>>
>> private String name;
>>
>> @Column(allowsNull="true")
>> @MemberOrder(sequence = "1")
>> public String getName() {
>> return name;
>> }
>>
>> public void setName(final String name) {
>> this.name = name;
>> }
>>
>> }
>>
>> Hth
>>
>> On 1 September 2015 at 20:44, Jeroen van der Wal <[email protected]>
>> wrote:
>>
>> > If you make your abstract class public it should work fine ;-)
>> >
>> > Cheers,
>> >
>> > Jeroen
>> >
>> > On 1 September 2015 at 15:12, Stephen Cameron <
>> [email protected]>
>> > wrote:
>> >
>> >> Here a two scenarios each with a Parent and Child Type, they should
>> give
>> >> the same result
>> >>
>> >> 1. Concrete Parent Type
>> >>
>> >> @PersistenceCapable()
>> >> public class ConcreteParentType {
>> >>
>> >> @PrimaryKey()
>> >> @Persistent(valueStrategy=IdGeneratorStrategy.INCREMENT)
>> >> private Long id;
>> >>
>> >> private String name;
>> >>
>> >> @Column(allowsNull="true")
>> >> @MemberOrder(sequence = "1")
>> >> public String getName() {
>> >> return name;
>> >> }
>> >>
>> >> public void setName(final String name) {
>> >> this.name = name;
>> >> }
>> >>
>> >> }
>> >>
>> >> @PersistenceCapable()
>> >> public class ChildTypeOfConcreteParentType extends ConcreteParentType {
>> >>
>> >>
>> >> private String description;
>> >>
>> >> @Column(allowsNull="true")
>> >> @MemberOrder(sequence = "2")
>> >> public String getDescription() {
>> >> return description;
>> >> }
>> >>
>> >> public void setDescription(final String description) {
>> >> this.description = description;
>> >> }
>> >>
>> >> }
>> >>
>> >> 2. Abstract Parent Type
>> >>
>> >> @PersistenceCapable()
>> >> @Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
>> >> abstract class AbstractParentType {
>> >>
>> >> @PrimaryKey()
>> >> @Persistent(valueStrategy=IdGeneratorStrategy.INCREMENT)
>> >> private Long id;
>> >>
>> >> private String name;
>> >>
>> >> @Column(allowsNull="true")
>> >> @MemberOrder(sequence = "1")
>> >> public String getName() {
>> >> return name;
>> >> }
>> >>
>> >> public void setName(final String name) {
>> >> this.name = name;
>> >> }
>> >>
>> >> }
>> >>
>> >> @PersistenceCapable()
>> >> public class ChildTypeOfAbstractParentType extends AbstractParentType {
>> >>
>> >> private String description;
>> >>
>> >> @Column(allowsNull="true")
>> >> @MemberOrder(sequence = "2")
>> >> public String getDescription() {
>> >> return description;
>> >> }
>> >>
>> >> public void setDescription(final String description) {
>> >> this.description = description;
>> >> }
>> >>
>> >> }
>> >>
>> >> In the seond scenario the name property doesn't appear, only the
>> >> description.
>> >>
>> >> The DomainService class for testing these two scenarios in the viewer
>> is
>> >> this:
>> >>
>> >> @DomainService(nature=NatureOfService.VIEW_MENU_ONLY)
>> >> @DomainServiceLayout(named = "DataNucleus", menuBar = MenuBar.PRIMARY,
>> >> menuOrder = "100")
>> >> public class Menu {
>> >>
>> >>
>> >>
>> >> public ChildTypeOfConcreteParentType
>> >> createChildTypeOfConcreteParentType() {
>> >> ChildTypeOfConcreteParentType childType = null;
>> >> try {
>> >> childType =
>> >> container.newTransientInstance(ChildTypeOfConcreteParentType.class);
>> >> childType.setName("ChildTypeOfConcreteParentType");
>> >> childType.setDescription("something descriptive");
>> >> container.persistIfNotAlready(childType);
>> >> } catch (Exception e) {
>> >> e.printStackTrace();
>> >> }
>> >> return childType;
>> >> }
>> >>
>> >> public ChildTypeOfAbstractParentType
>> >> createChildTypeOfAbstractParentType() {
>> >> ChildTypeOfAbstractParentType childType = null;
>> >> try {
>> >> childType =
>> >> container.newTransientInstance(ChildTypeOfAbstractParentType.class);
>> >> childType.setName("ChildTypeOfAbstractParentType");
>> >> childType.setDescription("something descriptive");
>> >> container.persistIfNotAlready(childType);
>> >> } catch (Exception e) {
>> >> e.printStackTrace();
>> >> }
>> >> return childType;
>> >> }
>> >>
>> >>
>> >>
>> >> @javax.inject.Inject
>> >> DomainObjectContainer container;
>> >>
>> >> }
>> >>
>> >>
>> >> On Tue, Sep 1, 2015 at 10:42 PM, Stephen Cameron <
>> >> [email protected]
>> >> > wrote:
>> >>
>> >> > Hi Jeroen, just noticed this after sending second update (winge).
>> >> >
>> >> > I'll send a test case now.
>> >> >
>> >> > On Tue, Sep 1, 2015 at 10:29 PM, Jeroen van der Wal <
>> >> [email protected]>
>> >> > wrote:
>> >> >
>> >> >> Hi Stephen,
>> >> >>
>> >> >> Can you share some code to support your case?
>> >> >>
>> >> >> Cheers,
>> >> >>
>> >> >> Jeroen
>> >> >>
>> >> >> On 1 September 2015 at 12:39, Stephen Cameron <
>> >> [email protected]
>> >> >> >
>> >> >> wrote:
>> >> >>
>> >> >> > Hi,
>> >> >> >
>> >> >> > I've been trying today to find solutions to what seem to be
>> >> Datanucleus
>> >> >> > issues, but without much success. So rather than solve the
>> problems
>> >> >> created
>> >> >> > in my refactoring of my application, which has been too hard
>> frankly,
>> >> >> I'm
>> >> >> > trying to start afresh with some simple test cases, show these
>> work,
>> >> >> then
>> >> >> > add more complexity till I get where I want to be.
>> >> >> >
>> >> >> > So, I am starting this approach and I immediately have an issue,
>> but
>> >> >> not a
>> >> >> > Datanucleus one, I find that the value properties of an abstract
>> >> parent
>> >> >> > class don't appear in the Wicket viewer, whereas they do if the
>> >> parent
>> >> >> > class is concrete. Is this correct and if so what is the reason?
>> >> >> >
>> >> >> > Thanks.
>> >> >> >
>> >> >>
>> >> >
>> >> >
>> >>
>> >
>> >
>>
>
>