Skip to Content
author's profile photo Former Member
Former Member

How can we remove the data from database?

Hi Team,

Please help me to solve this. How can we remove the data from database?

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 01, 2017 at 03:26 PM

    As you know you are dealing with Hybris Type system, when you talk about database. So never remove table or rows from physical database, unless of course you are smnd know what you are doing. The right approach is to use impex remove command on the type. This way you ensure that Hybris Type system is fully in compliance with the contract at physical layer of persistence. If you use, service layer you can use modelService to remove model (essentially logical type) that cascades the action to Physical layer.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 01, 2017 at 07:06 PM

    There are three ways of doing delete operation in Hybris 1) through hmc, backoffice or other admin portals. 2) through impex files. You can run impex from hac for example REMOVE Region;country(isocode);isocode[unique=true];isocodeShort;name[lang=en]; ;CN;CN-71;71;"Taiwan" ;CN;CN-91;91;"Xianggang" ;CN;CN-92;92;"Aomen" 3) By deleting directly from database.

    This is for data only. If you want to remove tables that can be only done through manual operation by dba. But you still need to remove from items.xml and clean up orphan types https://wiki.hybris.com/display/release5/Cleanup+Type+System

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 01, 2017 at 11:08 PM

    ,

    Hybris maintain a very complex structure when it comes to physically storing data onto a database. Hybris has its own customized ORM framework based on JPA persistence which is very well knitted around the type-system declared in the items.xml. Each item has a hybris generated PK value.

    Deleting objects, rows or columns directly in the database tables can be fatal, unless you completely understand the context around it. If you talk about deleting a particular itemtype say XYZ and its data directly from database, it involves deleting references from ComposedType table, XYZ table, and references of the XYZ objects from any relations, index created for this type, etc. So it is quite tricky to understand the exact mapping of itemtype to database tables, as hybris has a very different table naming pattern and it stores many objects in generic tables with PK reference for its actual type.

    For this reason, it is preferred to delete instances, relations, collection, a specific itemtype or its sub-type from the hybris context only which utilizes it own ORM framework to talk to database to perform the desired database operation. Hybris provides the following approach to delete/remove :

    • Using modelService.remove() or modelService.removeAll() APIs

    • From HMC

    • From BackOffice

    • Using groovy/shell or other scripting language from HAC

    • Using REMOVE keyword in ImpEx

    • Explicitly removing from database directly (highly discouraged)

    NOTE: If you want to delete directly from the database, you could use the default database GUI design and manipulation tools, and run SQL queries directly on the database. For e.g. if you use, MySQL as database, you could use MySQL Workbench to see the hybris tables, data, schema and run sql queries.

    For more details, you will have to elaborate your question? What exactly you want to delete from the database? A type, an instance of a type, a complete table for a given type or complete typesystem?

    Hope this helps!!

    Regards,

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2017 at 03:27 AM

    you can use below feature to finish this goal:

    1. modelService API

    2. HMC delete item

    3. Backoffice

    4. beanshell/groovy script in HAC

    5. run REMOVE mode ImpEx file in HAC

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.