{"id":23665876,"url":"https://github.com/alfonsog-dev/javamysqlorm","last_synced_at":"2025-09-01T18:32:16.025Z","repository":{"id":193174082,"uuid":"686514661","full_name":"AlfonsoG-dev/javaMysqlORM","owner":"AlfonsoG-dev","description":"Simple ORM in java","archived":false,"fork":false,"pushed_at":"2024-05-19T05:57:17.000Z","size":340,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-05-19T06:38:37.689Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlfonsoG-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-03T03:32:55.000Z","updated_at":"2024-05-19T05:57:20.000Z","dependencies_parsed_at":"2023-10-20T07:44:21.810Z","dependency_job_id":"d1527201-01e1-4741-b66e-be3ce9e76087","html_url":"https://github.com/AlfonsoG-dev/javaMysqlORM","commit_stats":null,"previous_names":["alfonsog-dev/java-mysql-eje","alfonsog-dev/javamysqlorm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlfonsoG-dev%2FjavaMysqlORM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlfonsoG-dev%2FjavaMysqlORM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlfonsoG-dev%2FjavaMysqlORM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlfonsoG-dev%2FjavaMysqlORM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlfonsoG-dev","download_url":"https://codeload.github.com/AlfonsoG-dev/javaMysqlORM/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231705132,"owners_count":18413966,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-29T06:18:27.375Z","updated_at":"2024-12-29T06:18:35.390Z","avatar_url":"https://github.com/AlfonsoG-dev.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Java MYSQL ORM \n\u003e- An ORM like app in java.\n\u003e- creates SQL sentences for MYSQL databases using java classes as models.\n\u003e\u003e- i try to replicate an ORM functionality in java for MYSQL.\n\n# Dependencies\n\n\u003e- [Java JDK 17.0.8](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)\n\u003e- [mysql connector 8.3.0](https://dev.mysql.com/downloads/connector/j/)\n\u003e- [javabuild tool](https://github.com/AlfonsoG-dev/javaBuild)\n\n# References\n\n\u003e- [mysql_query_examples](https://www.w3schools.com/mysql/)\n\u003e- [JDBC samples](https://www.javatpoint.com/PreparedStatement-interface)\n\n# Features\n- [x] dynamic query creation using class objects as table models.\n- [x] temporary tables using class objects as table models.\n- [x] normal CRUD operations and `INNER JOIN` as well.\n- [x] dynamic Migration using Annotations fields of the table model.\n- [x] accepts table relationships using the table Model Annotations.\n- [x] method to execute INSERT, UPDATE, DELETE operations using SQL sentences as parameters.\n- [x] method to SELECT operations using SQL sentences as parameters.\n- [x] `CREATE VIEW ` statement.\n- [x] `INSERT INTO ... SELECT` statement.\n- [x] prepared and normal statements\n\n-----\n\n# Normal Use\n\n[normal_samples](./src/Samples/Normal/QuerySamples.java)\n\n# Migration Use\n\n[migration_samples](./src/Samples/Migration/MigrationSamples.java)\n\n# Connection use\n\n[connection_samples](./src/Samples/ConnectionSamples.java)\n\n## Model Creation\n\u003e- A Class can be a model if implements `ModelMethods` interface\n\u003e\u003e- Model Methods have 2 methods and each one have their own purpose.\n```java\npublic class Model implements ModelMethods {\n    /**\n    * primary key for model always need to be id_pk\n    * if you put another you have to add id_pk to the end or at the start \n    * ejm: mode_id_pk\n    */\n    @TableProperties(\n        miConstraint = \"not null primary key auto_increment\",\n        miType = \"int\"\n    )\n    private int id_pk;   \n    /**\n    * a class another class member\n     */\n    @TableProperties(\n        miConstraint = \"not null\",\n        miType = \"varchar(100)\"\n    )\n    private String description;\n    public Model() {\n    }\n\n    // getter and setter\n\n    /**\n    * method to implement from ModelMethods.\n    * is used to get the model data in *column: value* format\n    */\n    @Override\n    public String getAllProperties() {\n        StringBuffer all = new StringBuffer();\n        if(this.getId_pk() \u003e 0) {\n            all.append(\"id_pk: \" + this.getId_pk() + \"\\n\");\n        }\n        if(this.getName() != null) {\n            all.append( \"name: \" + this.getName() + \"\\n\");\n        }\n        if(this.getDescription() != null) {\n            all.append( \"decription: \" + this.getDescription());\n        }\n        return all.toString();\n    }\n}\n```\n\u003e- if the model contains an FK column you must declare the reference inside de Annotation and separate the constraint with `.` before the FK reference\n\u003e\u003e- because of the nature of the migration operation.\n\n```java\n/**\n* foreign key de la cuenta al usuario\n* you have to add the id_fk to the end or start\n* ejm: model_id_fk | id_fk_model\n*/\n@TableProperties(\n    miConstraint = \"not null. foreign key('name of the fk') references `name of the table`(name of the pk) on delete cascade on update cascade\",\n    miType = \"int\"\n)\nprivate int user_id_fk;\n\n```\n---------\n\n# Compile And Execute\nThis project use [javaBuild_tool](https://github.com/AlfonsoG-dev/javaBuild) to build the project.\n\n\u003e- if you are not using vscode and need to compile the project with the `javac` CLI tool.\n\u003e- I include a `java-exe.ps1` shell script for powershell.\n\n## PowerShell script for compile and execute.\n\n```shell\n$clases = \"all the clases in the program\"\n$compilation = \"javac -d ./bin/\" + \"$clases\";\n$javaCommand = \"java -cp \" + '\"./bin;path to a custom jar file\" .\\src\\MainClass.java';\n$createJar = \"jar -cfm jarName.jar Manifesto.txt -C .\\bin\\ . -C .\\lib extracted file path\\ .\"\n$runCommand = \"$compilation\" + \" \u0026\u0026 \" + \"\u0026createJar\" + \" \u0026\u0026 \" + \"$javaCommand\"\nInvoke-Expression $runCommand\n```\n\u003e- if you need to add a custom jar file from another project\n```shell\n$compilation = \"javac -d ./bin/ -cp \" + '\" path to a custom jar file\"' + \"$clases\";\n```\n\u003e- if your need to create a jar file\n\u003e\u003e- add in the root of the project: `Manifesto.txt`\n```txt\nManifest-Version: 1.0\nMain-Class: MyMainClassName\nClass-Path: lib\\lib_dependency\\dependency.jar\n```\n\u003e- remember if you want the lib dependency as part of the jar build you must add it.\n\u003e\u003e- create a directory name: `extractionFile`\n\u003e\u003e- move the lib jar file dependency only to `extractionFile` directory.\n\u003e\u003e- in the `extractionFile` directory extract the jar file dependency.\n\u003e\u003e- finally for the ps1 build script add the following sentence.\n```\n$createJar = \"jar -cfm jarName.jar Manifesto.txt -C .\\bin\\ . -C .\\extractionFile\\lib extracted file path\\ .\"\n```\n\n--------\n\n# Disclaimer\n\u003e- this project is just for educational purposes.\n\u003e- security issues are not taken into account.\n\u003e- is not intended to make a full ORM program.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falfonsog-dev%2Fjavamysqlorm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falfonsog-dev%2Fjavamysqlorm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falfonsog-dev%2Fjavamysqlorm/lists"}