FAQ
Hello,
how can I create a custom Mysql adapter? I use cayenne 3.1M3.

I've tried:

1)
DataNode node = new DataNode(...);
dataNode.setAdapter(new MySQLAdapter());

2)
Provider<DbAdapter> adapterProvider = new Provider<DbAdapter>() {

public DbAdapter get() throws ConfigurationException {
MySQLAdapter adapter = new MySQLAdapter();
return adapter;
}
};
AutoAdapter autoAdapter = new AutoAdapter(adapterProvider, logger);

--------------------------------

everytime I get following Exception:
Exception in thread "main" org.apache.cayenne.CayenneRuntimeException:
[v.3.1M3 Sep 12 2011 19:59:45] java.lang.NullPointerException
at
org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:840)
at
org.apache.cayenne.access.DataDomainQueryAction.runQueryInTransaction(DataDomainQueryAction.java:392)
at
org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryAction.java:121)
at
org.apache.cayenne.access.DataDomain.onQueryNoFilters(DataDomain.java:708)
at
org.apache.cayenne.access.DataDomain$DataDomainQueryFilterChain.onQuery(DataDomain.java:958)
at org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java:698)
at
org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:336)
at
org.apache.cayenne.util.ObjectContextQueryAction.executePostCache(ObjectContextQueryAction.java:104)
at
org.apache.cayenne.util.ObjectContextQueryAction.execute(ObjectContextQueryAction.java:91)
at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:990)
at org.apache.cayenne.access.DataContext.performQuery(DataContext.java:979)
at
org.example.cayenne.persistent.DynamicMain.selectTutorial(DynamicMain.java:271)
at org.example.cayenne.persistent.DynamicMain.main(DynamicMain.java:252)
Caused by: java.lang.NullPointerException
at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:281)
at
org.apache.cayenne.access.DataDomainQueryAction.runQuery(DataDomainQueryAction.java:422)
at
org.apache.cayenne.access.DataDomainQueryAction.access$000(DataDomainQueryAction.java:69)
at
org.apache.cayenne.access.DataDomainQueryAction$2.transform(DataDomainQueryAction.java:395)
at
org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:828)
... 12 more

best regards

--
View this message in context: http://cayenne.195.n3.nabble.com/Myslq-Adapter-tp3828735p3828735.html
Sent from the Cayenne - User mailing list archive at Nabble.com.

Search Discussions

  • Andrus Adamchik at Mar 15, 2012 at 1:34 pm
    NPE is for JdbcEventLogger in the DataNode, not related to adapter.

    check DataDomainProvider.createAndInitDataDomain for how the DataNode is created. Specifically JdbcEventLogger is set explicitly:

    dataNode.setJdbcEventLogger(jdbcEventLogger);

    Andrus
    On Mar 15, 2012, at 9:19 AM, Sheldon wrote:

    Hello,
    how can I create a custom Mysql adapter? I use cayenne 3.1M3.

    I've tried:

    1)
    DataNode node = new DataNode(...);
    dataNode.setAdapter(new MySQLAdapter());

    2)
    Provider<DbAdapter> adapterProvider = new Provider<DbAdapter>() {

    public DbAdapter get() throws ConfigurationException {
    MySQLAdapter adapter = new MySQLAdapter();
    return adapter;
    }
    };
    AutoAdapter autoAdapter = new AutoAdapter(adapterProvider, logger);

    --------------------------------

    everytime I get following Exception:
    Exception in thread "main" org.apache.cayenne.CayenneRuntimeException:
    [v.3.1M3 Sep 12 2011 19:59:45] java.lang.NullPointerException
    at
    org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:840)
    at
    org.apache.cayenne.access.DataDomainQueryAction.runQueryInTransaction(DataDomainQueryAction.java:392)
    at
    org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryAction.java:121)
    at
    org.apache.cayenne.access.DataDomain.onQueryNoFilters(DataDomain.java:708)
    at
    org.apache.cayenne.access.DataDomain$DataDomainQueryFilterChain.onQuery(DataDomain.java:958)
    at org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java:698)
    at
    org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:336)
    at
    org.apache.cayenne.util.ObjectContextQueryAction.executePostCache(ObjectContextQueryAction.java:104)
    at
    org.apache.cayenne.util.ObjectContextQueryAction.execute(ObjectContextQueryAction.java:91)
    at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:990)
    at org.apache.cayenne.access.DataContext.performQuery(DataContext.java:979)
    at
    org.example.cayenne.persistent.DynamicMain.selectTutorial(DynamicMain.java:271)
    at org.example.cayenne.persistent.DynamicMain.main(DynamicMain.java:252)
    Caused by: java.lang.NullPointerException
    at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:281)
    at
    org.apache.cayenne.access.DataDomainQueryAction.runQuery(DataDomainQueryAction.java:422)
    at
    org.apache.cayenne.access.DataDomainQueryAction.access$000(DataDomainQueryAction.java:69)
    at
    org.apache.cayenne.access.DataDomainQueryAction$2.transform(DataDomainQueryAction.java:395)
    at
    org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:828)
    ... 12 more

    best regards

    --
    View this message in context: http://cayenne.195.n3.nabble.com/Myslq-Adapter-tp3828735p3828735.html
    Sent from the Cayenne - User mailing list archive at Nabble.com.
  • Wernke zur Borg at Mar 15, 2012 at 2:26 pm
    Hi,

    after a lot of trouble like yours I found that the easiest way is to set
    the DbAdapter class in the modeler. There is an extra tab "Adapter" on
    the DataNode configuration. You don't need to do anything in your source
    code (except defining your Adapter class).

    Wernke

    On 2012-03-15 14:19, Sheldon wrote:
    Hello,
    how can I create a custom Mysql adapter? I use cayenne 3.1M3.

    I've tried:

    1)
    DataNode node = new DataNode(...);
    dataNode.setAdapter(new MySQLAdapter());

    2)
    Provider<DbAdapter> adapterProvider = new Provider<DbAdapter>() {

    public DbAdapter get() throws ConfigurationException {
    MySQLAdapter adapter = new MySQLAdapter();
    return adapter;
    }
    };
    AutoAdapter autoAdapter = new AutoAdapter(adapterProvider, logger);

    --------------------------------

    everytime I get following Exception:
    Exception in thread "main" org.apache.cayenne.CayenneRuntimeException:
    [v.3.1M3 Sep 12 2011 19:59:45] java.lang.NullPointerException
    at
    org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:840)
    at
    org.apache.cayenne.access.DataDomainQueryAction.runQueryInTransaction(DataDomainQueryAction.java:392)
    at
    org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryAction.java:121)
    at
    org.apache.cayenne.access.DataDomain.onQueryNoFilters(DataDomain.java:708)
    at
    org.apache.cayenne.access.DataDomain$DataDomainQueryFilterChain.onQuery(DataDomain.java:958)
    at org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java:698)
    at
    org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:336)
    at
    org.apache.cayenne.util.ObjectContextQueryAction.executePostCache(ObjectContextQueryAction.java:104)
    at
    org.apache.cayenne.util.ObjectContextQueryAction.execute(ObjectContextQueryAction.java:91)
    at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:990)
    at org.apache.cayenne.access.DataContext.performQuery(DataContext.java:979)
    at
    org.example.cayenne.persistent.DynamicMain.selectTutorial(DynamicMain.java:271)
    at org.example.cayenne.persistent.DynamicMain.main(DynamicMain.java:252)
    Caused by: java.lang.NullPointerException
    at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:281)
    at
    org.apache.cayenne.access.DataDomainQueryAction.runQuery(DataDomainQueryAction.java:422)
    at
    org.apache.cayenne.access.DataDomainQueryAction.access$000(DataDomainQueryAction.java:69)
    at
    org.apache.cayenne.access.DataDomainQueryAction$2.transform(DataDomainQueryAction.java:395)
    at
    org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:828)
    ... 12 more

    best regards

    --
    View this message in context: http://cayenne.195.n3.nabble.com/Myslq-Adapter-tp3828735p3828735.html
    Sent from the Cayenne - User mailing list archive at Nabble.com.

    --
    /Wernke zur Borg
    *Rhea System S.A.*
    Robert-Bosch-Str. 7
    64293 Darmstadt / Germany
    Tel. +49-6151-8709591/


    This email (including any attachments) may contain confidential and/or privileged
    information or information otherwise protected from disclosure. If you are not the
    intended recipient, please notify the sender immediately, do not copy this message
    or any attachments and do not use it or any purpose or disclose its content to any
    person, but delete this message and any attachments from your system.
    RHEA System S.A. (RHEA) disclaims any and all liability if this email transmission
    was virus corrupted, altered or falsified.

    If a Non Disclosure Agreement (NDA) exists between RHEA and the receiving
    organization, then all contents shall be considered proprietary and covered under
    the NDA.
  • Andrus Adamchik at Mar 15, 2012 at 2:29 pm
    Sheldon is building Cayenne config in the code, bypassing XML model.

    On Mar 15, 2012, at 10:25 AM, Wernke zur Borg wrote:


    Hi,

    after a lot of trouble like yours I found that the easiest way is to set
    the DbAdapter class in the modeler. There is an extra tab "Adapter" on
    the DataNode configuration. You don't need to do anything in your source
    code (except defining your Adapter class).

    Wernke

    On 2012-03-15 14:19, Sheldon wrote:
    Hello,
    how can I create a custom Mysql adapter? I use cayenne 3.1M3.

    I've tried:

    1)
    DataNode node = new DataNode(...);
    dataNode.setAdapter(new MySQLAdapter());

    2)
    Provider<DbAdapter> adapterProvider = new Provider<DbAdapter>() {

    public DbAdapter get() throws ConfigurationException {
    MySQLAdapter adapter = new MySQLAdapter();
    return adapter;
    }
    };
    AutoAdapter autoAdapter = new AutoAdapter(adapterProvider, logger);

    --------------------------------

    everytime I get following Exception:
    Exception in thread "main" org.apache.cayenne.CayenneRuntimeException:
    [v.3.1M3 Sep 12 2011 19:59:45] java.lang.NullPointerException
    at
    org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:840)
    at
    org.apache.cayenne.access.DataDomainQueryAction.runQueryInTransaction(DataDomainQueryAction.java:392)
    at
    org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryAction.java:121)
    at
    org.apache.cayenne.access.DataDomain.onQueryNoFilters(DataDomain.java:708)
    at
    org.apache.cayenne.access.DataDomain$DataDomainQueryFilterChain.onQuery(DataDomain.java:958)
    at org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java:698)
    at
    org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:336)
    at
    org.apache.cayenne.util.ObjectContextQueryAction.executePostCache(ObjectContextQueryAction.java:104)
    at
    org.apache.cayenne.util.ObjectContextQueryAction.execute(ObjectContextQueryAction.java:91)
    at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:990)
    at org.apache.cayenne.access.DataContext.performQuery(DataContext.java:979)
    at
    org.example.cayenne.persistent.DynamicMain.selectTutorial(DynamicMain.java:271)
    at org.example.cayenne.persistent.DynamicMain.main(DynamicMain.java:252)
    Caused by: java.lang.NullPointerException
    at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:281)
    at
    org.apache.cayenne.access.DataDomainQueryAction.runQuery(DataDomainQueryAction.java:422)
    at
    org.apache.cayenne.access.DataDomainQueryAction.access$000(DataDomainQueryAction.java:69)
    at
    org.apache.cayenne.access.DataDomainQueryAction$2.transform(DataDomainQueryAction.java:395)
    at
    org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:828)
    ... 12 more

    best regards

    --
    View this message in context: http://cayenne.195.n3.nabble.com/Myslq-Adapter-tp3828735p3828735.html
    Sent from the Cayenne - User mailing list archive at Nabble.com.

    --
    /Wernke zur Borg
    *Rhea System S.A.*
    Robert-Bosch-Str. 7
    64293 Darmstadt / Germany
    Tel. +49-6151-8709591/


    This email (including any attachments) may contain confidential and/or privileged
    information or information otherwise protected from disclosure. If you are not the
    intended recipient, please notify the sender immediately, do not copy this message
    or any attachments and do not use it or any purpose or disclose its content to any
    person, but delete this message and any attachments from your system.
    RHEA System S.A. (RHEA) disclaims any and all liability if this email transmission
    was virus corrupted, altered or falsified.

    If a Non Disclosure Agreement (NDA) exists between RHEA and the receiving
    organization, then all contents shall be considered proprietary and covered under
    the NDA.
  • Sheldon at Mar 15, 2012 at 2:43 pm
    You are right Andrus,

    the JdbcEventLogger of the adapter is null.
    How can I initialize the Logger?

    Sheldon


    --
    View this message in context: http://cayenne.195.n3.nabble.com/Myslq-Adapter-tp3828735p3828969.html
    Sent from the Cayenne - User mailing list archive at Nabble.com.
  • Andrus Adamchik at Mar 15, 2012 at 2:50 pm
    It is provided by Cayenne via injection. You can inject it in your provider. Check org.apache.cayenne.configuration.server.DataDomainProvider, it has this line:

    @Inject
    protected JdbcEventLogger jdbcEventLogger;

    Andrus

    On Mar 15, 2012, at 10:43 AM, Sheldon wrote:

    You are right Andrus,

    the JdbcEventLogger of the adapter is null.
    How can I initialize the Logger?

    Sheldon


    --
    View this message in context: http://cayenne.195.n3.nabble.com/Myslq-Adapter-tp3828735p3828969.html
    Sent from the Cayenne - User mailing list archive at Nabble.com.
  • Sheldon at Mar 15, 2012 at 3:21 pm
    Sorry Andrus, but I don't really understand DI and I don't found good
    explanations of it.
    Can you give me some advice or good links?

    thanks
    Sheldon

    --
    View this message in context: http://cayenne.195.n3.nabble.com/Myslq-Adapter-tp3828735p3829085.html
    Sent from the Cayenne - User mailing list archive at Nabble.com.
  • Andrus Adamchik at Mar 15, 2012 at 3:59 pm
    Try this Cayenne Guide: http://people.apache.org/~aadamchik/misc/cayenne-guide-03152012.pdf

    It has a lot of blanks, but the DI related stiff is described in some detail. (Note that all the property names there correspond to the trunk build, and will not work with M3, but the general advice is fully applicable).

    Andrus

    On Mar 15, 2012, at 11:20 AM, Sheldon wrote:
    Sorry Andrus, but I don't really understand DI and I don't found good
    explanations of it.
    Can you give me some advice or good links?

    thanks
    Sheldon

    --
    View this message in context: http://cayenne.195.n3.nabble.com/Myslq-Adapter-tp3828735p3829085.html
    Sent from the Cayenne - User mailing list archive at Nabble.com.
  • Sheldon at Mar 15, 2012 at 4:17 pm
    Thank you Andrus,
    I don't found this instruction.

    Sheldon

    --
    View this message in context: http://cayenne.195.n3.nabble.com/Myslq-Adapter-tp3828735p3829244.html
    Sent from the Cayenne - User mailing list archive at Nabble.com.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriescayenne
postedMar 15, '12 at 1:20p
activeMar 15, '12 at 4:17p
posts9
users3
websitecayenne.apache.org

People

Translate

site design / logo © 2022 Grokbase