on 2018 Dec 05 11:41 PM
Hi,
I have a doubt, later of an audit performed on my company. When I create a flexible search query in a DAO class, it is considered good practice to use aliases for types and attributes? Or, should I should refer directly to the name of the Type:
For example, should I do this?
select {p.pk}, {p.name} from {Product as p}
Or, is this better?
select {Product.pk}, {Product.name} from {Product}
regards!
Amy
Request clarification before answering.
Alias is better because many types share the same attribute names and you'll get ambiguous column errors when doing joins. This is good.
select {p.pk}, {p.name} from {Product as p}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I also agree with Leo's answer.
But if you have only Type, you don't need to use alias. This should be enough:
SELECT {pk}, {name} FROM {Product}
If you join with other Types, an alias will be useful:
SELECT
{p.code}, {cg.code}, {cat.id}, {catver.version}
FROM
{Product AS p
JOIN CategoryProductRelation AS rel ON {p.PK} = {rel.target}
JOIN Category AS cg ON {rel.source} = {cg.PK}
JOIN CatalogVersion AS catver ON {catver.pk}={cg.catalogVersion}
JOIN Catalog AS cat ON {cat.pk}={catver.catalog}
}
WHERE
{cat.id} LIKE 'Default'
AND {catver.version} LIKE 'Staged'
Other useful references:
FlexibleSearch Tips and Tricks: https://help.hybris.com/1808/hcd/8bc36ba986691014b48be171221d1f4f.html
FlexibleSearch Samples: https://help.hybris.com/1808/hcd/8bc33bb28669101481ccfb446695e9de.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
19 | |
17 | |
3 | |
2 | |
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.