Hi Steve,
funny, hit almost the same issue just today while implementing ISIS-1182
[1]. It's fixed on 1.9.0-SNAPSHOT but might also work fine on 1.8.0.
As you've discovered, DN can sometimes trip up if we rely on it to lazily
build its metamodel. In the past we've seen issues this occur with it
submitting invalid SQL (when it only knows about a superclass table but not
yet any of the subclasses), and we've also seen deadlocks on HSQLDB when
DDL is intermingled with DML. I think you are seeing this second case
yourself.
The fix - that works on 1.9.0-SNAPSHOT at least - is to use specify the
isis.persistor.datanucleus.RegisterEntities.packagePrefix
key in isis.properties. This causes Isis to go searching for and
registering all domain entities.
We introduced this key a good while back, but I also recall that in one of
the more recent versions (1.7.0, 1.8.0?) it got broken again. Anyway, I've
added some migration notes for 1.8.0 because with ISIS-1182 it seems to be
more critical again to get it right.
Let me know how you get on.
Thx
Dan
[1] https://issues.apache.org/jira/browse/ISIS-1182
[2]
http://isis.apache.org/migration-notes.html#_migration-notes_1.8.0-to-1.9.0_specify-all-dom-packages
On 31 July 2015 at 14:35, Stephen Cameron <[email protected]>
wrote:
> More info, yes it seems the Volunteer table is not created at the same time
> as the other tables, until I actually try to add an entry, Isis seems to
> check for it, finds it missing and creates it.I am doing almost exactly the
> same procedure successfully with another table that is already created,
> participant.
>
> Here is the current striped down Volunteer class defintion:
> package au.com.scds.chats.dom.modules.volunteer;
>
> import javax.jdo.annotations.Column;
> import javax.jdo.annotations.IdentityType;
>
> import org.apache.isis.applib.DomainObjectContainer;
> import org.apache.isis.applib.annotation.MemberOrder;
>
> import au.com.scds.chats.dom.modules.general.Person;
>
>
> @javax.jdo.annotations.PersistenceCapable(identityType =
> IdentityType.DATASTORE)
> @javax.jdo.annotations.DatastoreIdentity(strategy =
> javax.jdo.annotations.IdGeneratorStrategy.IDENTITY, column = "id")
> public class Volunteer {
>
> // {{ Person (property)
> private Person person;
>
> @Column(allowsNull="false")
> @MemberOrder(sequence = "1")
> public Person getPerson() {
> return person;
> }
>
> public void setPerson(final Person person) {
> this.person = person;
> }
>
> // }}
>
> @javax.inject.Inject
> @SuppressWarnings("unused")
> private DomainObjectContainer container;
>
> // endregion
> }
>
>
>
> On Fri, Jul 31, 2015 at 10:38 PM, Stephen Cameron <
> [email protected]> wrote:
>
> > Hi folks
> >
> > I have a problem that I cannot solve and hoping someone might have seen
> > similar.
> >
> > When I create a new entity the server freezes, its just the one kind of
> > entity.
> >
> > In the server console I see the following output.
> >
> > 22:13:26,989 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > ALTER TABLE "Activity" ADD CONSTRAINT "Activity_FK2" FOREIGN KEY
> > ("activities_id_OID") REFERENCES "Participant" ("id")
> > 22:13:26,991 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > Execution Time = 2 ms
> > 22:13:26,991 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > Creating foreign key constraint : "Activity_FK1" in catalog "" schema ""
> > 22:13:26,991 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > ALTER TABLE "Activity" ADD CONSTRAINT "Activity_FK1" FOREIGN KEY
> > ("provider_id_OID") REFERENCES "Provider" ("id")
> > 22:13:26,992 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > Execution Time = 1 ms
> > 22:13:26,993 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > Creating index "Activity_N49" in catalog "" schema ""
> > 22:13:26,993 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > CREATE INDEX "Activity_N49" ON "Activity" ("provider_id_OID")
> > 22:13:26,993 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > Execution Time = 0 ms
> > 22:13:26,994 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > Schema Transaction committing with connection
> >
> "org.datanucleus.store.rdbms.datasource.dbcp.PoolingDataSource$PoolGuardConnectionWrapper@587ed84a
> > "
> > 22:13:26,994 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > Schema Transaction closing with connection
> >
> "org.datanucleus.store.rdbms.datasource.dbcp.PoolingDataSource$PoolGuardConnectionWrapper@587ed84a
> > "
> > 22:13:33,718 [PropertiesFactory 455726379@qtp-1318209130-0 INFO ]
> > Loading properties files from
> >
> jar:file:/C:/Users/stevec/.m2/repository/org/apache/wicket/wicket-extensions/6.17.0/wicket-extensions-6.17.0.jar!/org/apache/wicket/extensions/Initializer.properties
> > with loader
> > org.apache.wicket.resource.IsoPropertiesFilePropertiesLoader@723b0f4d
> > 22:13:55,556 [PropertiesFactory 455726379@qtp-1318209130-0 INFO ]
> > Loading properties files from
> >
> jar:file:/C:/Users/stevec/.m2/repository/org/apache/isis/viewer/isis-viewer-wicket-ui/1.9.0-SNAPSHOT/isis-viewer-wicket-ui-1.9.0-SNAPSHOT.jar!/org/apache/isis/viewer/wicket/ui/components/actions/ActionParametersFormPanel.properties
> > with loader
> > org.apache.wicket.resource.IsoPropertiesFilePropertiesLoader@723b0f4d
> > 1
> > 2
> > 3
> > 22:14:05,008 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > Column ""Volunteer"."id"" added to internal representation of table.
> > 22:14:05,008 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > Field [DATASTORE_ID] -> Column(s) ["Volunteer"."id"] using mapping of
> type
> > "org.datanucleus.store.rdbms.mapping.java.DatastoreIdMapping"
> > (org.datanucleus.store.rdbms.mapping.datastore.BigIntRDBMSMapping)
> > 22:14:05,009 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > Table "Volunteer" will manage the persistence of the fields for class
> > au.com.scds.chats.dom.modules.volunteer.Volunteer (inheritance
> > strategy="new-table")
> > 22:14:05,009 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > Column ""Volunteer"."person_id_OID"" added to internal representation of
> > table.
> > 22:14:05,009 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > Field [au.com.scds.chats.dom.modules.volunteer.Volunteer.person] ->
> > Column(s) ["Volunteer"."person_id_OID"] using mapping of type
> > "org.datanucleus.store.rdbms.mapping.java.PersistableMapping"
> > (org.datanucleus.store.rdbms.mapping.datastore.BigIntRDBMSMapping)
> > 22:14:05,009 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > Column ""Volunteer"."status"" added to internal representation of table.
> > 22:14:05,010 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > Field [au.com.scds.chats.dom.modules.volunteer.Volunteer.status] ->
> > Column(s) ["Volunteer"."status"] using mapping of type
> > "org.datanucleus.store.rdbms.mapping.java.EnumMapping"
> > (org.datanucleus.store.rdbms.mapping.datastore.VarCharRDBMSMapping)
> > 22:14:05,010 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > Table/View "Volunteer" has been initialised
> > 22:14:05,010 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > Schema Transaction started with connection
> >
> "org.datanucleus.store.rdbms.datasource.dbcp.PoolingDataSource$PoolGuardConnectionWrapper@1855dae
> "
> > with isolation "serializable"
> > 22:14:05,015 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > Check of existence of "Volunteer" returned no table
> > 22:14:05,015 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > Creating table "Volunteer"
> > 22:14:05,015 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > CREATE TABLE "Volunteer"
> > (
> > "id" BIGINT GENERATED BY DEFAULT AS IDENTITY,
> > "person_id_OID" BIGINT NULL,
> > "status" NVARCHAR(255) NOT NULL,
> > CONSTRAINT "Volunteer_PK" PRIMARY KEY ("id")
> > )
> > 22:14:05,016 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > Execution Time = 1 ms
> > 22:14:05,020 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > Creating foreign key constraint : "Volunteer_FK1" in catalog "" schema ""
> > 22:14:05,021 [Schema 455726379@qtp-1318209130-0 DEBUG]
> > ALTER TABLE "Volunteer" ADD CONSTRAINT "Volunteer_FK1" FOREIGN KEY
> > ("person_id_OID") REFERENCES "Person" ("id")
> >
> > I'm still no debugging properly yet, so the 1,2,3 are from the following
> > routine
> >
> > public Volunteer create(
> > final @ParameterLayout(named = "First name") String
> firstname,
> > final @ParameterLayout(named = "Middle name(s)") String
> > middlename,
> > final @ParameterLayout(named = "Surname") String surname) {
> > System.out.println("1");
> > final Volunteer volunteer = container
> > .newTransientInstance(Volunteer.class);
> > final Person person =
> container.newTransientInstance(Person.class);
> > person.setFirstname(firstname);
> > person.setMiddlename(middlename);
> > person.setSurname(surname);
> > container.persistIfNotAlready(person);
> > System.out.println("2");
> > volunteer.setPerson(person);
> > container.persistIfNotAlready(volunteer);
> > System.out.println("3");
> > return volunteer;
> > }
> >
> > What seems strange in the output is that the table Volunteer doesn't seem
> > to be created in the same way as other tables. In fact its after a
> > transaction is committed:
> >
> > DEBUG] Schema Transaction closing with connection
> >
> "org.datanucleus.store.rdbms.datasource.dbcp.PoolingDataSource$PoolGuardConnectionWrapper@587ed84a
> > "
> >
> > Also, that Volunteer table is created after the calls to add an entry in
> > the create method.
> >
> > HFH
> > Steve
> >
> >
>