Yea, I guess it is *possible* that the Rule's Id is more than 767 bytes.
But I'd only expect that if an application identity was being (mis-)used,
not a datastore identity.

We'll have to wait til Marianne posts the Rule class, I guess.

Dan

On 14 April 2015 at 22:51, Martin Grigorov <[email protected]> wrote:

> According to http://stackoverflow.com/a/24042737/497381 you can enable
> larger limit for unique key prefix: innodb_large_prefix=on
>
> Check also
>
> http://dba.stackexchange.com/questions/49913/specified-key-was-too-long-max-key-length-is-1000-bytes-in-mysql-5-6
>
> Martin Grigorov
> Freelancer, available for hire!
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Tue, Apr 14, 2015 at 11:40 PM, Dan Haywood <
> [email protected]>
> wrote:
>
> > I suspect that you'll find that the Rule class already has a
> > @PersistenceCapable annotation; otherwise you wouldn't have seen any DDL
> > for the "create table rule".
> >
> > I was going to say that I thought that the DataNuclues enhancer hasn't
> > correctly run, but I think that usually manifests itself as some other
> > problem.
> >
> > Even so, I do think that, somehow, DN is trying to serialize the Rule
> > instance rather than store the rule's Id as a foreign key.
> >
> > Two questions:
> > - can you post the full source code for the Rule class?
> > - does the app run using hsqldb:mem (rather than MySQL).
> >
> > Thx
> > Dan
> >
> >
> >
> > On 14 April 2015 at 22:15, Martin Grigorov <[email protected]> wrote:
> >
> > > Hi,
> > >
> > > You should annotate Rule class with @PersistenceCapable as SimpleObject
> > > does:
> > >
> > >
> >
> https://github.com/apache/isis/blob/c3740b13177e4db7d7cafae3c1dd839b997fc806/example/application/simpleapp/dom/src/main/java/domainapp/dom/modules/simple/SimpleObject.java#L38
> > >
> > > Martin Grigorov
> > > Freelancer, available for hire!
> > > Wicket Training and Consulting
> > > https://twitter.com/mtgrigorov
> > >
> > > On Tue, Apr 14, 2015 at 4:16 PM, Marianne Hagaseth <
> > > [email protected]> wrote:
> > >
> > > > But how do I annotate the Rule class as @PersistenceCapable ?
> > > >
> > > > -----Original Message-----
> > > > From: Dan Haywood [mailto:[email protected]]
> > > > Sent: 20. mars 2015 10:42
> > > > To: users
> > > > Subject: Re: MySQL and "Specified key was too long"
> > > >
> > > > Hi Marianne,
> > > >
> > > > My *guess* is that the Rule class is not annotated as
> > @PersistenceCapable
> > > > but is serializable, and so DataNucleus is serializing the object as
> a
> > > > byte[] array, and that is overflowing the limit for MySQL.
> > > >
> > > > Double check what the schema is that's being created; you can get DN
> to
> > > > log this by setting:
> > > >
> > > > log4j.logger.DataNucleus.Datastore.Schema=DEBUG, Console
> > > >
> > > > in WEB-INF/logging.properties .
> > > >
> > > > You could also set:
> > > >
> > > > log4j.logger.DataNucleus.Datastore.Native=DEBUG, Console
> > > >
> > > > in order to inspect the SQL INSERT statement.
> > > >
> > > > Let us know how you get on.
> > > >
> > > > Cheers
> > > > Dan
> > > >
> > > >
> > > >
> > > >
> > > > On 20 March 2015 at 09:35, Marianne Hagaseth <
> > > > [email protected]> wrote:
> > > >
> > > > > Hi there,
> > > > > I am trying to add this property (see code further down) and then
> > > > > using mySQL for the persistence.
> > > > > However, it fails with a MySQL error: "Specified key was too long;
> > max
> > > > > key length is 767 bytes"
> > > > >
> > > > > Anyone who have ideas for where to start searching for the error?
> > > > >
> > > > > Best,
> > > > > Marianne Hagaseth.
> > > > >
> > > > > //region > rule (property)
> > > > >    private Rule rule;
> > > > >    @javax.jdo.annotations.Column(name="ruleId",allowsNull="true")
> > > > >    @MemberOrder(name="General", sequence="80")
> > > > >    public Rule getRule() {
> > > > >                return rule;
> > > > >    }
> > > > >    public void setRule(final Rule rule) {
> > > > >        this.rule = rule;
> > > > >    }
> > > > >    //endregion
> > > > >
> > > > >
> > > > >
> > > > > 10:20:45,861  [Schema               main       DEBUG]  Execution
> > Time =
> > > > > 123 ms
> > > > > 10:20:45,865  [Datastore            main       ERROR]  An exception
> > was
> > > > > thrown while adding/validating class(es) : Specified key was too
> > long;
> > > > > max key length is 767 bytes
> > > > > com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
> Specified
> > > > > key was too long; max key length is 767 bytes
> > > > >        at
> > > > > sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> > > > > Method)
> > > > >        at
> > > > >
> > > >
> > >
> >
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
> > > > >        at
> > > > >
> > > >
> > >
> >
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> > > > >        at
> > > > > java.lang.reflect.Constructor.newInstance(Constructor.java:526)
> > > > >
> > > > >
> > > > >        at org.mortbay.jetty.Server.doStart(Server.java:224)
> > > > >        at
> > > > >
> > >
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
> > > > >        at
> > > > >
> > > >
> > >
> >
> org.apache.isis.core.webserver.WebServerBootstrapper.bootstrap(WebServerBootstrapper.java:85)
> > > > >        at
> > > > org.apache.isis.core.webserver.WebServer.run(WebServer.java:103)
> > > > >        at
> > > > org.apache.isis.core.webserver.WebServer.main(WebServer.java:67)
> > > > >        at org.apache.isis.WebServer.main(WebServer.java:25)
> > > > >
> > > > > 10:20:45,865  [Datastore            main       ERROR]  An exception
> > was
> > > > > thrown while adding/validating class(es) : Specified key was too
> > long;
> > > > > max key length is 767 bytes
> > > > > com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
> Specified
> > > > > key was too long; max key length is 767 bytes
> > > > >        at
> > > > > sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> > > > > Method)
> > > > >        at
> > > > >
> > > >
> > >
> >
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
> > > > >        at
> > > > >
> > > >
> > >
> >
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> > > > >        at
> > > java.lang.reflect.Constructor.newInstance(Constructor.java:526)
> > > > >        at com.mysql.jdbc.Util.handleNewInstance(Util.java:377)
> > > > >        at com.mysql.jdbc.Util.getInstance(Util.java:360)
> > > > >        at
> > > > > com.mysql.jdbc.SQLError.createSQLException(SQLError.java:978)
> > > > >
> > > > >
> > > > > Caused by:
> com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
> > > > > Specified key was too long; max key length is 767 bytes
> > > > >        at
> > > > > sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> > > > > Method)
> > > > >        at
> > > > >
> > > >
> > >
> >
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
> > > > >        at
> > > > >
> > > >
> > >
> >
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> > > > >        at
> > > java.lang.reflect.Constructor.newInstance(Constructor.java:526)
> > > > >        ... 54 more
> > > > > 10:20:46,204  [WicketFilter         main       ERROR]  The
> > > initialization
> > > > > of an application with name 'WicketFilter' has failed.
> > > > > com.google.inject.ProvisionException: Guice provision errors:
> > > > >
> > > > > 1) Error in custom provider,
> > > > > org.datanucleus.exceptions.NucleusDataStoreException: Error(s) were
> > > > > found while auto-creating/validating the datastore for classes. The
> > > > > errors are printed in the log, and are attached to this exception.
> > > > >   at
> > > > >
> > org.apache.isis.core.runtime.runner.IsisInjectModule.provideIsisSystem
> > > > > (IsisInjectModule.java:132)
> > > > >
> > > > >
> > > > >    //region > rule (property)
> > > > >    private Rule rule;
> > > > >    @javax.jdo.annotations.Column(name="ruleId",allowsNull="true")
> > > > >    @MemberOrder(name="General", sequence="80")
> > > > >    public Rule getRule() {
> > > > >                return rule;
> > > > >    }
> > > > >    public void setRule(final Rule rule) {
> > > > >        this.rule = rule;
> > > > >    }
> > > > >    //endregion
> > > > >
> > > > >
> > > > >
> > > >
> > >
> >
>

Reply via email to