Re: How to create entities in the database using java events just as like we do in JDBC

2023-03-22 Thread Michael Brohl

Hi Mahi,

Apache OFBiz relies on a database agnostic layer which is called the 
Entity Engine.


For OFBiz, tables and views only exist if they are defined in the entity 
model, so it is useless to create them through direct JDBC/SQL 
statements if you want to use them within OFBiz.


If you can give us the reasoning behind your attempt we might be able to 
help find a solution. Please be aware that OFBiz has a mechanism to 
automatically create tables, views, references and indexes from the 
entity definitions.


Best regards,

Michael Brohl

ecomify GmbH - www.ecomify.de


Am 22.03.23 um 13:57 schrieb Mahi maheshwari:

Hello Community,

I need help in creating entities through java events but not using
entitymodel.xml file.
like we do in java for creating entities, example was given below for
reference.
EXAMPLE:
try(Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
Statement stmt = conn.createStatement();
) {
String sql = "CREATE TABLE REGISTRATION " +
"(id INTEGER not NULL, " +
" first VARCHAR(255), " +
" last VARCHAR(255), " +
" age INTEGER, " +
" PRIMARY KEY ( id ))";
  stmt.executeUpdate(sql);
}catch(SQLException  e){
e.printStackTrace();
}

how can I achieve this in ofbiz using java events?

Thank you,
maheshwari.

1.



How to create entities in the database using java events just as like we do in JDBC

2023-03-22 Thread Mahi maheshwari
Hello Community,

I need help in creating entities through java events but not using
entitymodel.xml file.
like we do in java for creating entities, example was given below for
reference.
EXAMPLE:
try(Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
Statement stmt = conn.createStatement();
) {
String sql = "CREATE TABLE REGISTRATION " +
"(id INTEGER not NULL, " +
" first VARCHAR(255), " +
" last VARCHAR(255), " +
" age INTEGER, " +
" PRIMARY KEY ( id ))";
 stmt.executeUpdate(sql);
}catch(SQLException  e){
e.printStackTrace();
}

how can I achieve this in ofbiz using java events?

Thank you,
maheshwari.

   1.