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