<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: How do i save data to a database (Customer/User) in CRM and CX Q&amp;A</title>
    <link>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050737#M403300</link>
    <description>&lt;P&gt;Hi Avinash,&lt;/P&gt;
&lt;P&gt;I have updated in my comment's above how I initialize the modelService.&lt;/P&gt;
&lt;P&gt;Thank you,
&lt;/P&gt;</description>
    <pubDate>Mon, 01 Apr 2019 09:00:38 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2019-04-01T09:00:38Z</dc:date>
    <item>
      <title>How do i save data to a database (Customer/User)</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaq-p/12050728</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;
&lt;P&gt;I am new to hybris development, and I have created a custom extension in my hybris.
I don't really understand how to use an existing service to persist my Customer data to the database.&lt;/P&gt;
&lt;P&gt;I have tried using the ModelService, but i do not know how to initialize it.&lt;/P&gt;
&lt;P&gt;It would be great if anyone can help me understand how data can be persisted in Hybris Commerce.&lt;/P&gt;
&lt;P&gt;Thank You,
&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2019 07:41:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaq-p/12050728</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-03-29T07:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do i save data to a database (Customer/User)</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050729#M403292</link>
      <description>&lt;P&gt;Hi  - you need to inject ModelService as shown below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; @Resource
 private ModelService modelService;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then after setting the values in your model object, you need to save the model using &lt;CODE&gt;modelService.save(your-model-object)&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;If you still get NPE, please inject &lt;CODE&gt;ModelService&lt;/CODE&gt; as given below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; @Autowired
 private ModelService modelService;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and use the following in your Spring Configuration file: &lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; &amp;lt;context:annotation-config/&amp;gt;
 &amp;lt;context:component-scan  base-package="your-package-name"/&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can find many examples in Test classes. A &lt;STRONG&gt;File Search&lt;/STRONG&gt; in ee with the parameters as given in the screenshot will return the classes you can refer for your requirement.&lt;/P&gt;
&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1719322-12507-screenshot-2019-03-29-101630.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2019 11:19:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050729#M403292</guid>
      <dc:creator>arvind-kumar_avinash</dc:creator>
      <dc:date>2019-03-29T11:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do i save data to a database (Customer/User)</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050730#M403293</link>
      <description>&lt;P&gt;Hi Avinash,&lt;/P&gt;
&lt;P&gt;Thanks for getting back on this. I have tried the method above, but i am still getting a null pointer exception on line 35. Here is my code, please let me know what am I doing wrong here.&lt;/P&gt;
&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1719256-12508-picture.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2019 16:50:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050730#M403293</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-03-29T16:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do i save data to a database (Customer/User)</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050731#M403294</link>
      <description>&lt;P&gt;I am not sure if you are really getting the NPE at line#35. Could you please replace line#31 with &lt;CODE&gt;CustomerModel customer = modelService.create(CustomerModel.class);&lt;/CODE&gt; and see if you get the NPE at line#31? If yes, probably your server has started with some errors.
&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2019 19:54:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050731#M403294</guid>
      <dc:creator>arvind-kumar_avinash</dc:creator>
      <dc:date>2019-03-29T19:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do i save data to a database (Customer/User)</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050732#M403295</link>
      <description>&lt;P&gt;Have you added the dependency in spring.xml file?
&lt;/P&gt;</description>
      <pubDate>Sat, 30 Mar 2019 20:48:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050732#M403295</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-03-30T20:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do i save data to a database (Customer/User)</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050733#M403296</link>
      <description>&lt;P&gt;Hi Avinash,&lt;/P&gt;
&lt;P&gt;Thank you for your quick reply. I tried again with your suggestion and NPE occurs on line 31 with the modelService.create().&lt;/P&gt;
&lt;P&gt;Do i need to maintain dependencies in my extension dependency.xml if I am using  CustomerModel? Maybe there is a runtime error occuring because of this?
&lt;/P&gt;</description>
      <pubDate>Sun, 31 Mar 2019 18:20:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050733#M403296</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-03-31T18:20:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do i save data to a database (Customer/User)</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050734#M403297</link>
      <description>&lt;P&gt;Hi Ashish,&lt;/P&gt;
&lt;P&gt;Do you mean the CustomerModel dependency in my extension spring dependency xml?&lt;/P&gt;
&lt;P&gt;If so, then no i have not. I will try again.
&lt;/P&gt;</description>
      <pubDate>Sun, 31 Mar 2019 18:22:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050734#M403297</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-03-31T18:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do i save data to a database (Customer/User)</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050735#M403298</link>
      <description>&lt;P&gt;Did you try injecting ModelService as given below?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;  @Autowired
  private ModelService modelService;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;P&gt; Do i need to maintain dependencies in
 my extension dependency.xml if I am
 using CustomerModel? Maybe there is a
 runtime error occuring because of
 this?
&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
No. This problem is because &lt;CODE&gt;ModelService&lt;/CODE&gt; is not getting instantiated.</description>
      <pubDate>Sun, 31 Mar 2019 18:56:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050735#M403298</guid>
      <dc:creator>arvind-kumar_avinash</dc:creator>
      <dc:date>2019-03-31T18:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do i save data to a database (Customer/User)</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050736#M403299</link>
      <description>&lt;P&gt;Yes, I changed it to the autowired annotation.&lt;/P&gt;
&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1719344-12511-capture.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 04:58:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050736#M403299</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-04-01T04:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do i save data to a database (Customer/User)</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050737#M403300</link>
      <description>&lt;P&gt;Hi Avinash,&lt;/P&gt;
&lt;P&gt;I have updated in my comment's above how I initialize the modelService.&lt;/P&gt;
&lt;P&gt;Thank you,
&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 09:00:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050737#M403300</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-04-01T09:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do i save data to a database (Customer/User)</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050738#M403301</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I solved my issue, to initialize the modelService, we can use the code below. Also if we are performing CRUD operations, we need to provide the Uid of the model, before save().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; final ModelService modelService = Registry.getApplicationContext().getBean("modelService", ModelService.class);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Apr 2019 09:01:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/how-do-i-save-data-to-a-database-customer-user/qaa-p/12050738#M403301</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-04-01T09:01:52Z</dc:date>
    </item>
  </channel>
</rss>

