on 12-01-2017 3:07 PM
Hi Team,
Please help me to solve this. How can we remove the data from database?
you can use below feature to finish this goal:
modelService API
HMC delete item
Backoffice
beanshell/groovy script in HAC
run REMOVE mode ImpEx file in HAC
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
,
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,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.