{"id":36421620,"url":"https://github.com/intellinside/hibernate-foreign-ref-support","last_synced_at":"2026-01-14T02:20:12.679Z","repository":{"id":331913540,"uuid":"1108365574","full_name":"intellinside/hibernate-foreign-ref-support","owner":"intellinside","description":"A Hibernate ORM extension that provides a convenient way to define foreign keys through annotations on entity fields.","archived":false,"fork":false,"pushed_at":"2025-12-02T12:03:07.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-11T19:13:40.551Z","etag":null,"topics":["foreign-keys","hibernate","jpa-entities"],"latest_commit_sha":null,"homepage":"","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/intellinside.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-02T11:06:39.000Z","updated_at":"2025-12-04T14:22:10.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/intellinside/hibernate-foreign-ref-support","commit_stats":null,"previous_names":["intellinside/hibernate-foreign-ref-support"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/intellinside/hibernate-foreign-ref-support","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intellinside%2Fhibernate-foreign-ref-support","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intellinside%2Fhibernate-foreign-ref-support/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intellinside%2Fhibernate-foreign-ref-support/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intellinside%2Fhibernate-foreign-ref-support/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/intellinside","download_url":"https://codeload.github.com/intellinside/hibernate-foreign-ref-support/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intellinside%2Fhibernate-foreign-ref-support/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["foreign-keys","hibernate","jpa-entities"],"created_at":"2026-01-11T17:38:38.753Z","updated_at":"2026-01-14T02:20:12.664Z","avatar_url":"https://github.com/intellinside.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hibernate Foreign Reference Support\n\n\nA Hibernate ORM extension that provides a convenient way to define foreign keys (Foreign Keys) through annotations on entity fields.\n\n## Description\n\nА library that allows declarative definition of foreign key relationships between database tables through a simple `@ForeignRef` annotation. This extension works at the Hibernate metadata level, using the `AdditionalMappingContributor` mechanism, and automatically creates foreign key constraints during session initialization.\n\n## Features\n\n- 🎯 **Easy to Use** — simply add the `@ForeignRef` annotation to an entity field\n- 🔄 **Automatic Naming** — automatically generates constraint names according to Hibernate's naming strategy\n- 🎨 **Flexible** — supports both explicit target column specification and automatic primary key detection\n- 📝 **Convention Respecting** — respects Hibernate's column and table naming strategies\n- ⚡ **Minimal Dependencies** — requires only Hibernate Core (in `provided` scope)\n\n\n## Requirements\n\n- **Java 21+** \n- **Hibernate ORM 6.6.36+** — works with modern versions of Hibernate\n\n## Installation\n\n### Maven\n\nAdd the dependency to your `pom.xml`:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.intellinside\u003c/groupId\u003e\n    \u003cartifactId\u003ehibernate-foreign-key-support\u003c/artifactId\u003e\n    \u003cversion\u003e0.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Gradle\n\n```gradle\nimplementation 'io.github.intellinside:hibernate-foreign-key-support:0.1.0'\n```\n\n## Quick Start\n\n### Basic Example\n\n```java\n@Entity\n@Table(name = \"orders\")\npublic class Order {\n    @Id\n    @GeneratedValue(strategy = GenerationType.IDENTITY)\n    private Long id;\n\n    @ForeignRef(entity = Customer.class)\n    @Column(name = \"customer_id\")\n    private Long customerId;\n\n    private LocalDateTime createdAt;\n\n    // Getters and Setters\n}\n\n@Entity\n@Table(name = \"customers\")\npublic class Customer {\n    @Id\n    @GeneratedValue(strategy = GenerationType.IDENTITY)\n    private Long id;\n\n    private String name;\n    private String email;\n\n    // Getters and Setters\n}\n```\n\nIn this example, a foreign key constraint will be automatically created that links the `customer_id` column of the `orders` table to the primary key of the `customers` table.\n\n### Example with Explicit Target Column\n\n```java\n@Entity\n@Table(name = \"products\")\npublic class Product {\n    @Id\n    @GeneratedValue(strategy = GenerationType.IDENTITY)\n    private Long id;\n\n    private String name;\n\n    @Column(name = \"category_code\")\n    private String categoryCode;\n\n    // Getters and Setters\n}\n\n@Entity\n@Table(name = \"categories\")\npublic class Category {\n    @Id\n    @GeneratedValue(strategy = GenerationType.IDENTITY)\n    private Long id;\n\n    @Column(name = \"code\", unique = true)\n    private String code;\n\n    private String name;\n\n    // Getters and Setters\n}\n\n// In the Product class:\n@ForeignRef(entity = Category.class, referencedColumn = \"code\")\n@Column(name = \"category_code\")\nprivate String categoryCode;\n```\n\n### Example with Custom Constraint Name\n\n```java\n@Entity\n@Table(name = \"order_items\")\npublic class OrderItem {\n    @Id\n    @GeneratedValue(strategy = GenerationType.IDENTITY)\n    private Long id;\n\n    @ForeignRef(entity = Order.class, name = \"fk_item_order\")\n    @Column(name = \"order_id\")\n    private Long orderId;\n\n    @ForeignRef(entity = Product.class, name = \"fk_item_product\")\n    @Column(name = \"product_id\")\n    private Long productId;\n\n    private Integer quantity;\n    private BigDecimal price;\n\n    // Getters and Setters\n}\n```\n\n## License\n\nThe project is distributed under the **MIT License**. For details, see the [LICENSE](LICENSE) file.\n\n## Support and Issues\n\nIf you have questions, problems, or suggestions:\n\n1. Check [Issues](https://github.com/intellinside/hibernate-foreign-ref-support/issues)\n2. Create a new Issue with a detailed description\n3. Attach a code example demonstrating the problem\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintellinside%2Fhibernate-foreign-ref-support","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintellinside%2Fhibernate-foreign-ref-support","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintellinside%2Fhibernate-foreign-ref-support/lists"}