Hi Lucas,
Basically, I have different clients which are using my library to generate 
sql. Currently, we have to 2 seperate repos one for code generation and 
another one is using database-schema file generated by first library to 
generate jooq tables at build time. And right now its a very tedious 
process to connect their database first and run code generation tool to 
generate database-schema.xml file and create a pr in second repo with that 
database schema file and again start the application. So if there is a way 
at runtime only we connect to their database and generate jooq tables on 
the fly and create sql query. 

Regards
Deepankar Gupta

On Thursday, October 12, 2023 at 12:36:20 PM UTC+5:30 lukas...@gmail.com 
wrote:

> Hi Deepankar,
>
> Why do you want to generate classes at runtime?
>
> On Thu, Oct 12, 2023 at 9:01 AM deepankar gupta <deepankar...@gmail.com> 
> wrote:
>
>> Hi Lucas,
>>
>> Currently, I am using database-schema.xml file and jooq-codegen-maven 
>> plugin to generate jooq tables at build time. But Now I want to create jooq 
>> tables at runtime. So I was going through some articles where we can 
>> generate jooq tables at runtime using groovy or kotlin script. Is this a 
>> correct way or any other alternative.
>> // Create a Groovy script that generates jOOQ classes def script = """ 
>> import org.jooq.codegen.GenerationTool import org.jooq.meta.jaxb.* import 
>> org.jooq.meta.extensions.* import org.jooq.meta.* import java.io.* def 
>> config = new Configuration() config.withJdbc(new Jdbc() .withDriver("c
>> om.mysql.cj.jdbc.Driver") .withUrl("jdbc:mysql:
>> //localhost:3306/mydatabase") .withUser("myuser") .withPassword(
>> "mypassword")) config.withGenerator(new Generator() .withDatabase(new 
>> Database() .withName("org.jooq.meta.mysql.MySQLDatabase") .withIncludes(
>> ".*") .withExcludes("") .withInputSchema("public")) .withGenerate(new 
>> Generate() .withPojos(true) .withDaos(true)) .withTarget(new Target() 
>> .withPackageName("com.example.generated") .withDirectory(
>> "/path/to/generated/classes"))) def tool = new GenerationTool() 
>> tool.run(config, new PrintWriter(System.out)) """ // Evaluate the Groovy 
>> script to generate jOOQ classes GroovyShell shell = new GroovyShell(); 
>> shell.evaluate(script); // Use the generated jOOQ classes in your 
>> application DSLContext context = DSL.using(dataSource, SQLDialect.MYSQL); 
>> MyTableRecord record = 
>> context.selectFrom(MY_TABLE).where(MY_TABLE.ID.eq(1)).fetchOne();
>>
>> On Thursday, October 12, 2023 at 12:11:32 PM UTC+5:30 lukas...@gmail.com 
>> wrote:
>>
>>> Hi Deepankar,
>>>
>>> Thank you for your message.
>>>
>>> What are you trying to do?
>>>
>>> Best Regards,
>>> Lukas
>>>
>>> On Thu, Oct 12, 2023 at 8:02 AM deepankar gupta <deepankar...@gmail.com> 
>>> wrote:
>>>
>>>> can jooq create classes from database-schema file at runtime??
>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "jOOQ User Group" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to jooq-user+...@googlegroups.com.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/jooq-user/8419fe0a-469f-4be7-8124-167584db1f05n%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/jooq-user/8419fe0a-469f-4be7-8124-167584db1f05n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "jOOQ User Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to jooq-user+...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jooq-user/ba7a1f97-7e3e-4337-98ec-007ab0166aecn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jooq-user/ba7a1f97-7e3e-4337-98ec-007ab0166aecn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jooq-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/0f96324f-d32e-43bb-a1ca-18ff6f6379een%40googlegroups.com.

Reply via email to