What to configure in entityengine.xml file in Ofbiz? - datasource

I am new to Ofbiz and I am creating a datasource for my postgres database as below:
<datasource name="localpostgres"
helper-class="org.ofbiz.entity.datasource.GenericHelperDAO"
schema-name="public"
field-type-name="postgres"
check-on-start="false"
add-missing-on-start="false"
use-fk-initially-deferred="false"
alias-view-columns="false"
join-style="ansi"
use-binary-type-for-blob="true"
use-order-by-nulls="true"
result-fetch-size="50"> <!-- Comment out the result-fetch-size attribute for jdbc driver versions older than 8.0.
Not recommended to use those though. They are archived unsupported versions: http://jdbc.postgresql.org/download.html -->
<read-data reader-name="tenant"/>
<read-data reader-name="seed"/>
<read-data reader-name="seed-initial"/>
<read-data reader-name="demo"/>
<read-data reader-name="ext"/>
<read-data reader-name="ext-test"/>
<read-data reader-name="ext-demo"/>
<inline-jdbc
jdbc-driver="org.postgresql.Driver"
jdbc-uri="jdbc:postgresql://127.0.0.1:5432/dummy?stringtype=unspecified"
jdbc-username="postgres"
jdbc-password="root"
isolation-level="ReadCommitted"
pool-minsize="2"
pool-maxsize="250"
time-between-eviction-runs-millis="600000"/>
but when i run it populates my database with nearly 850 default entities. Then to solve this i set the property add-missing-on-start="false" now it doesn't loads the default tables but it executes the select query related to that tables causing the exception as below:
[java] Message: org.ofbiz.entity.GenericDataSourceException: SQL Exception while executing the following:SELECT JOB_ID, JOB_NAME, RUN_TIME, POOL_ID, STATUS_ID, PARENT_JOB_ID, PREVIOUS_JOB_ID, SERVICE_NAME, LOADER_NAME, MAX_RETRY, CURRENT_RETRY_COUNT, AUTH_USER_LOGIN_ID, RUN_AS_USER, RUNTIME_DATA_ID, RECURRENCE_INFO_ID, TEMP_EXPR_ID, CURRENT_RECURRENCE_COUNT, MAX_RECURRENCE_COUNT, RUN_BY_INSTANCE_ID, START_DATE_TIME, FINISH_DATE_TIME, CANCEL_DATE_TIME, JOB_RESULT, LAST_UPDATED_STAMP, LAST_UPDATED_TX_STAMP, CREATED_STAMP, CREATED_TX_STAMP FROM public.JOB_SANDBOX WHERE ((RUN_BY_INSTANCE_ID = ? AND (STATUS_ID = ? OR STATUS_ID = ? OR STATUS_ID = ?))) ORDER BY START_DATE_TIME ASC (ERROR: relation "public.job_sandbox" does not exist
now help me to prevent these default entities related operation from its execution.Thank You...

Related

Apache Drill Timestampdiff on Oracle DB

Hey everyone im relativly new to Apache Drill and im having troubles converting my Oracle specific sql scripts (pl/sql) to Drill based querys.
For example i have a Scripts who checks for processed data in the last X Days.
In this script im using the the sysdate function.
Here is my old script:
SELECT i.id,i.status,status_text,i.kunnr,i.bukrs,i.belnr,i.gjahr,event,i.sndprn,i.createdate,executedate,tstamp,v.typ_text,i.docnum,i.description, i.*
FROM in_job i JOIN vstatus_injob v ON i.id= v.id
WHERE 1=1
AND i.createdate > sysdate - 30.5
order by i.createdate desc;
When i looked up in terms of drill specific Datetime Diff functions i found "TIMESTAMPDIFF".
So here is my "drillified" script:
SELECT i.id, i.status, status_text, i.kunnr, i.bukrs, i.belnr, i.gjahr, i.event, i.sndprn, i.createdate, i.executedate, i.tstamp,v.typ_text,i.docnum,i.description,i.*
FROM SchemaNAME.IN_JOB i JOIN SchemaNAME.VSTATUS_INJOB v ON i.id=v.id
WHERE TIMESTAMPDIFF(DAY, CURRENT_TIMESTAMP, i.createdate) >=30
And the Error that is returned reads like this:
DATA_READ ERROR: The JDBC storage plugin failed while trying setup the SQL query.
By further inspection i can see the Oracle specific error that reads:
Caused by: java.sql.SQLSyntaxErrorException: ORA-00904: "TIMESTAMPDIFF": invalid ID
So now my question:
I thought apache drill replaces the function "TIMSTAMPDIFF" at runtime. But from what i can see in the logs its more like that Drill Hands over the Function Call "TIMESTAMPDIFF" to the Oracle database.
If thats true, how could i change my script to calculate the time difference (in days) and compare it to an int (ie 30 in the script).
If i use sysdate like above Apache Drill jumps in and says it doesnt know "sysdate".
How would you guyes handle that?
Thanks in advance and so long
:)
I have found a solution...
Just in Case someone (or even me in the future) is having a similar problem.
{
"queryType": "SQL",
"query": "select to_char(SELECT CURRENT_TIMESTAMP - INTERVAL XX MONTH FROM (VALUES(1)),'dd.MM.yy')"
}
With some to_char and the use of the CURRENT_TIMESTAMP - Interval Function Calls i can get everything i needed.
I took the query above packed it into an Grafana Variable, named it "timeStmpDiff" and then queried everything with an json Api Call to my Drill instance.
Basically:
"query" : "SELECT i.id, i.status, status_text, i.kunnr, i.bukrs, i.belnr, i.gjahr, i.event, i.sndprn, i.createdate, i.executedate, i.tstamp,v.typ_text,i.docnum,i.description,i.* FROM ${Schema}.IN_JOB i JOIN ${Schema}.VSTATUS_INJOB v ON i.id=v.id WHERE i.createdate >= '${timeStmpDiff}' order by i.createdate desc"
You can, of course query it in on go with an subselect.
But because i use grafana it made sense to me to bundle that in a Variable.

"IN" support for joins

We're trying to connect Pentaho BI to ClickHouse and sometimes Pentaho generates queries as such:
select
...
from
date_dimension_table,
fact_table,
other_dimension_table
where
fact_table.fact_date = date_dimension_table.date
and date_dimension_table.calendar_year = 2019
and date_dimension_table.month_name in ('April', 'June', ...)
and fact_table.other_dimension_id = other_dimension_table.id
and other_dimension_table.code in ('code1', 'code2', ...)
group by
date_dimension_table.calendar_year,
date_dimension_table.month_name,
other_dimension_table.code;
It produces ClickHouse error: Code: 403, e.displayText() = DB::Exception: Invalid expression for JOIN ON. Expected equals expression, got (code AS c2) IN ('code1', 'code2', ...). Supported syntax: JOIN ON Expr([table.]column, ...) = Expr([table.]column, ...) [AND Expr([table.]column, ...) = Expr([table.]column, ...)...] (version 19.15.3.6 (official build))
Engines used for tables: fact_table - MergeTree, both dimensions - TinyLog.
Thus, questions:
Can this problem be solved by changing table engines? Unfortunately, we can't change query, it's autogenerated.
If not, are there any plans for supporting joins with in clause in ClickHouse in the nearest future?
Thanx.
This issue has been fixed beginning with ClickHouse release v20.3.2.1, 2020-03-12 (see Issue 7314), so you need to upgrade CH.
! Don't forget to check all backward-incompatible changes (see changelog).
Let's reproduce this problem on CH 19.15.3 revision 54426 to get the error you described:
Received exception from server (version 19.15.3):
Code: 403. DB::Exception: Received from localhost:9000. DB::Exception: Invalid expression for JOIN ON. Expected equals expression, got code IN ('code1', 'code2'). Supported syntax: JOIN ON Expr([table.]column, ...) = Expr([table.]column, ...) [AND Expr([table.]column, ...) = Expr([table.]column, ...) ...].
Now execute this query on the latest version of CH (20.3.7 revision 54433) to make sure that it works correctly:
docker pull yandex/clickhouse-server:latest
docker run -d --name ch_test_latest yandex/clickhouse-server:latest
docker exec -it ch_test_latest clickhouse-client
# create tables as described below
..
# execute test query
..
Test preparation:
create table date_dimension_table (
date DateTime,
calendar_year Int32,
month_name String
) Engine = Memory;
create table fact_table (
fact_date DateTime,
other_dimension_id Int32
) Engine = Memory;
create table other_dimension_table (
id Int32,
code String
) Engine = Memory;
Test query:
SELECT
date_dimension_table.calendar_year,
date_dimension_table.month_name,
other_dimension_table.code
FROM date_dimension_table
,fact_table
,other_dimension_table
WHERE (fact_table.fact_date = date_dimension_table.date)
AND (date_dimension_table.calendar_year = 2019)
AND (date_dimension_table.month_name IN ('April', 'June'))
AND (fact_table.other_dimension_id = other_dimension_table.id)
AND (other_dimension_table.code IN ('code1', 'code2'))
GROUP BY
date_dimension_table.calendar_year,
date_dimension_table.month_name,
other_dimension_table.code

org.h2.jdbc.JdbcSQLException: Unknown data type: "DATEADD"; SQL statement

I'm using h2 to inject the db during run time and testing, everything was working fine until I started trying to make the date field current, not hard-coded.
I thought it was related to the jdbc version I've and updated spring jdbc library to be the latest, but that didn't solve the problem.
This is the code I'm using to inject the data both on run-time and testing :
This code runs during run-time, and it works perfectly before I tried to make the date current.
ResourceDatabasePopulator resourceDatabasePopulator = new ResourceDatabasePopulator();
resourceDatabasePopulator.addScript(new ClassPathResource("schema.sql"));
resourceDatabasePopulator.addScript(new ClassPathResource("data.sql"));
DatabasePopulatorUtils.execute(resourceDatabasePopulator, dataSource); // This is what the DataSourceInitializer does.
For testing purpose, I'm using this code, as I mentioned, it was working perfectly before I tried to make the date current.
DataSource dataSource = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2)
.addScript("classpath:schema.sql")
.addScript("classpath:data.sql")
.build();
data.sql file
INSERT INTO TABLE_X (
dayxx,
xxx
) VALUES
(CONVERT(char(50), DATEADD('DAY', -1,CURRENT_DATE()),126),'xxx')
Exception
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: Unknown data type: "DATEADD"; SQL statement:
INSERT INTO TABLE_X ( dayxx, xxx ) VALUES (CONVERT(char(50), DATEADD('DAY', -1,CURRENT_DATE()),126),'XXX') [50004-200]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:505)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:429)
at org.h2.message.DbException.get(DbException.java:205)
at org.h2.message.DbException.get(DbException.java:181)
at org.h2.command.Parser.parseColumnWithType(Parser.java:5971)
at org.h2.command.Parser.readFunctionParameters(Parser.java:3793)
at org.h2.command.Parser.readFunction(Parser.java:3772)
at org.h2.command.Parser.readTerm(Parser.java:4305)
at org.h2.command.Parser.readFactor(Parser.java:3343)
at org.h2.command.Parser.readSum(Parser.java:3330)
at org.h2.command.Parser.readConcat(Parser.java:3305)
at org.h2.command.Parser.readCondition(Parser.java:3108)
at org.h2.command.Parser.readExpression(Parser.java:3059)
at org.h2.command.Parser.parseValuesForCommand(Parser.java:1877)
at org.h2.command.Parser.parseInsertGivenTable(Parser.java:1817)
at org.h2.command.Parser.parseInsert(Parser.java:1749)
at org.h2.command.Parser.parsePrepared(Parser.java:954)
at org.h2.command.Parser.parse(Parser.java:843)
at org.h2.command.Parser.parse(Parser.java:815)
at org.h2.command.Parser.prepareCommand(Parser.java:738)
at org.h2.engine.Session.prepareLocal(Session.java:657)
at org.h2.engine.Session.prepareCommand(Session.java:595)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1235)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:212)
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201)
at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:472)
... 53 more
As reported in the docs, Convert function looks like this:
CONVERT ( value , dataType )
Converts a value to another data type.
Example:
CONVERT(NAME, INT)
Since you're passing
CONVERT(char(50), DATEADD('DAY', -1,CURRENT_DATE()),126)
The error states that DATEADD isn't a valid data type, since it's the value, not the type, so try using the right syntax.

dm_folder_r is not registered or you do not have access to it in documentum

I am a newbie to documentum and i am trying to run the following query:
select distinct A.*,A.i_chronicle_id,A.r_full_content_size,B.r_folder_path,B.r_object_id as folder_id
from dm_document A, dm_folder_r B
where any A.i_folder_id = B.r_object_id and B.r_folder_path is not null
for getting the folder path for the documents
I am getting the following error:
[DM_QUERY_E_TABLE_NO_ACCESS]error:
"The table, gwdmpr69.dm_folder_r, is not registered or you do not have access to it."; ERRORCODE: 100; NEXT: null
please help me what should I do to resolve the error
The easiest way to solve this, is to use DM_FOLDER (instead of DM_FOLDER_R) and the ENABLE (ROW_BASED) hint.
I just modified and run your query successfully :
select distinct A.*,A.i_chronicle_id,A.r_full_content_size,
B.r_folder_path,B.r_object_id as folder_id
from dm_document A, dm_folder B
where any A.i_folder_id = B.r_object_id
and B.r_folder_path is not null
ENABLE (ROW_BASED)
Please note that you are querying all the dm_documents in your Documentum system, which may result in a very large result set. Consider reducing your result set by adding more conditions to your where clause.
Try to use either dm_dbo.dm_folder_r or just dm_folder and ANY B.r_folder_path IS NOT NULL

DB2 query error during the retrieval of a CLOB field

From Java I am doing the following query on DB2:
SELECT * FROM PRV_PRE_ACTIVATION WHERE TRANSACTION_ID = ?
The field TRANSACTION_ID is a VARCHAR of length 32. I set the parameter in the preparedStatement using the setString method.
I get the error:
com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-270, SQLSTATE=42997, SQLERRMC=63, DRIVER=3.59.81
at com.ibm.db2.jcc.am.dd.a(dd.java:676)
at com.ibm.db2.jcc.am.dd.a(dd.java:60)
at com.ibm.db2.jcc.am.dd.a(dd.java:127)
at com.ibm.db2.jcc.am.bn.c(bn.java:2546)
at com.ibm.db2.jcc.am.bn.d(bn.java:2534)
at com.ibm.db2.jcc.am.bn.a(bn.java:2026)
at com.ibm.db2.jcc.t4.cb.g(cb.java:140)
at com.ibm.db2.jcc.t4.cb.a(cb.java:40)
at com.ibm.db2.jcc.t4.q.a(q.java:32)
at com.ibm.db2.jcc.t4.rb.i(rb.java:135)
at com.ibm.db2.jcc.am.bn.gb(bn.java:1997)
at com.ibm.db2.jcc.am.cn.pc(cn.java:3009)
at com.ibm.db2.jcc.am.cn.b(cn.java:3786)
at com.ibm.db2.jcc.am.cn.bc(cn.java:678)
at com.ibm.db2.jcc.am.cn.executeQuery(cn.java:652)
Where the sqstate means "Capability is not supported by this version of the DB2 application requester, DB2 application server, or the combination of the two." But I don't use any strange functionality.
I have tried using an squ client the query:
SELECT * FROM PRV_PRE_ACTIVATION where transaction_id='A'
And it goes ok.
What is the cause of the problem?
UPDATE: The code where the statement is prepared:
s = con.prepareStatement(sSQL,
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
Try changing to a specified list of columns in the select list -- my guess is you have a user defined column type (or some other type) which is not supported by your driver. For example, does the statement
SELECT TRANSACTION_ID FROM PRV_PRE_ACTIVATION WHERE TRANSACTION_ID = ?
work? If so then start adding columns in and you will find the problem column.
I've came across this problem lately, and after some searching on web, I've came across this link:
DB2 SQL error: SQLCODE: -270, SQLSTATE: 42997, SQLERRMC: 63
, which specifies this:
A column with a LOB type, distinct type on a LOB type, or
structured type cannot be specified in the select-list of an
insensitive scrollable cursor.
With help from an colleague, we came to this conclusion:
1, Q: When will you get this "SQLCODE=-204, SQLSTATE=42704" exception?
A: When a scrollable PreparedStatement is prepared & executed, yet there are [B|C]LOB fields exist in the select list. e.g.:
String strQuery = "SELECT NUMBER_FIELD, CHAR_FIELD, CLOB_FIELD FROM TABLE_NAME WHERE CONDITION IS TRUE;"
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, REsultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery(strQuery); //and this exception will be thrown here
2, Q: So what's the solution if we want to get rid of it when [B|C]LOB fields are queried?
A: Try to use ResultSet.TYPE_FORWARD_ONLY while creating the query statement.e.g.:
stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
Or simply try this one:
stmt = conn.createStatement();
Note that the same rules apply to conn.prepareStatement() too. You may refer to Java API doc for more information.