I have an EntityCondition
and I want to get SQL from it. For example
EntityCondition: partyId = 'admin'
-> SQL: party_id = 'admin'
I have tried to find in OFBiz project, but I have not found anything.
I have an EntityCondition
and I want to get SQL from it. For example
EntityCondition: partyId = 'admin'
-> SQL: party_id = 'admin'
I have tried to find in OFBiz project, but I have not found anything.
There's a general rule in OFBiz: entities and fields are defined in CamelCase, like PartyAttribute or productId. Entities begin with an uppercase letter (like a Java class) and fields begin with a lowercase letter (like a Java class attribute).
An uppercase letter inside the entity or field is converted to "_[lowercase]".
So
EntityCondition: partyId = 'admin'
-> SQL: party_id = 'admin'
A full select for entity PartyAttribute would be
SELECT * FROM PARTY_ATTRIBUTE WHERE PARTY_ID = 'admin'
You may try
makeWhereString(ModelEntity modelEntity, List<EntityConditionParam> entityConditionParams, DatasourceInfo datasourceInfo)
to achieve this programmatically, but I haven't tried it.
In
\ofbiz_src\framework\entity\src\org\ofbiz\entity\datasource\GenericDAO.java
you will see something like (In Apache Ofbiz 13, it stand about in about line 808 or nearby)
makeOffsetString(sqlBuffer, findOptions);
String sql = sqlBuffer.toString();
Add a line of code for printing query
makeOffsetString(sqlBuffer, findOptions);
String sql = sqlBuffer.toString();
System.out.println("SQL query: >>>" + sql);
By this way, you just able see query with parameter ?
, you cannot see value of parameter ?
in real world, like HQL query log in Hibernate.