Tag: ORM

How to Set Up a Composite Primary Key in jOOQ and Hibernate

In today’s article, we will take a look at composite primary key support in two top Java ORMs: jOOQ and Hibernate . We’ll look at a couple examples, learn how column configuration looks in Hibernate, and how support is organized in jOOQ.Thecomposite primary keyis a key that consists of more than one column, and its column combination guarantees its uniqueness.To handle the connection to the database, the application uses libraries known as object-relational mappers, or ORMs. Let’s see how jOOQ and Hibernate support this functionality.

SQLite Tools for Objective-C

The most common way to implement database functionalities in iOS applications is definitely Apple’s Core Data. However, its architecture is really Apple-like: it doesn’t let you see anything happening inside and the structure is hidden from you. That’s why some people dislike Core Data and prefer to stick with an SQLite database – even though SQLite is not supported natively.Fortunately, you are not forced to use core SQLite API in pure C. The iOS developers’ community has already delivered tools to make communication with an SQLite database easier.

A Comparison of Android ORMs

Although mobile apps do not rely on databases as much as, say, web applications, mobile app developers should still be interested in databases. There are better database solutions for Android apps than a native SQLite library; we’ll nominate ORMs (Object Relational Mapping) as one of them.ORMs make developers’ lives easier. They let us avoid struggling with building queries by concatenating strings or manually handling the connection with database. Typos are less of threat to your queries. And, with ORMs taking care of security, you don’t have to worry about resistance to injection attacks. You can focus on your application functionalities and let the database do its job.

Business Logic in the Database. Yes or No? It Depends!

We’ve had tremendously positive feedback on my recent article that talked about “Why SQL is neither legacy, nor low-level, nor difficult, nor the wrong place for (business) data logic, but simply awesome” both within the blog’s comment section as well as on reddit .However, one of the sections triggered very controversial feedback. Clearly, not everyone agreed to:Fallacy #5: The database is the wrong place for business logicNow this is really the biggest of all fallacies. Who said that? Some guy from the 90s who had written a book on Object-Oriented Design Patterns? Of course, if you blindly follow random architecture rules, this may apply to you. But then, beware that you’re following 10-20 year-old “legacy” principles by not using SQL (see also

How to Create a Spark REST API With jOOQ

I’ve been testing a ton of frameworks lately – good and otherwise. One of them, the Java micro framework Spark , really amazed me with its simplicity and rapid development capabilities. In this article, we’ll examine an example of Spark’s usefulness by creating a REST API.So, without further ado, let’s see how to store, retrieve, update and delete some information in a PostgreSQL database using jOOQ ORM over a RESTful API in a simple To-do app.

Generate jOOQ Classes With Vertabelo and Gradle

jOOQ is a Java Object-Relational Mapper that lets you build type safe SQL queries through its fluent API. Using built-in Vertabelo support we can generate sufficient code from the previously designed model. Generated Java classes correspond to database tables, records, etc. This time, we automate this process by using Gradle build system.There are two ways to generate ready to use Java classes with Vertabelo : Generate jOOQ classes via Vertabelo XML

Generate jOOQ Classes With Vertabelo and Maven

jOOQ provides an easy way to automate the process of generating the java classes that represent database tables, records, etc. via thejooq-codegen-mavenplugin. This time we let Maven worry about downloading the required JAR files and generating Java code that lets you build typesafe SQL queries through jOOQ’s fluent API.There are two ways to generate ready to use Java classes with Maven and Vertabelo: Generate jOOQ classes via Vertabelo XML

ORMs Under the Hood

It often happens that if something is loved, it is also hated with the same power. The idea of object relational mapping fits into this concept perfectly. You will definitely come across many opposite points and fierce discussions as well as unwavering advocates and haters. So if you have ever asked whether to use ORM or not, the answer “it depends” will not be enough.What Is an Object-Relational Mapping (ORM)?Object-relational mapping refers to synchronization between two different representations of data. From one side, there is a relational database, where the data is represented in terms of tuples, grouped into relations, while in application we manipulate objects.

jOOQ and Vertabelo – Getting Started

jOOQ and Vertabelo perfectly complement each other in the application development lifecycle. With Vertabelo you can easily design a database structure that saves you from writing DDL code manually, while jOOQ handles the generation of Java classes corresponding to database tables, and allows to construct SQL queries through its fluent API.The integration of Vertabelo and jOOQ has been the subject of several articles published on our blog. Unfortunately, all of them, including

How You Can Use Hibernate With a Database Modeling Tool

Before writing this article, I talked to a group of software engineers who use Hibernate on a daily basis in their work. Some of them work for small companies (up to 20 developers on site) while others are employed in corporations known world-wide that employ over 100,000 IT professionals. This gave me an insight into how development with Hibernate is organized in different companies.There are several approaches to creating SQL scripts and Hibernate O/R Mapping classes.

How to Generate Flask-SQLAlchemy Models Using Vertabelo

Flask is a web microframework for Python. It uses Flask-SQLAlchemy for object relational mapping. It is a Flask wrapper for SQLAlchemy – a powerful relational database framework that offers a high level ORM and low level access to a database’s native SQL functionality.For each database table, SQLAlchemy uses a regular Python class with attributes that match the columns of a corresponding database table. The database instance from Flask-SQLAlchemy provides a base class for models called

Side by Side: Doctrine2 and Propel 2

When you start working with data in an application, you may need to use an object-relational mapper (ORM), a layer between the database and application.For PHP the two most frequently used ORM’s are Doctrine and Propel . That’s why I decided to compare the main features of Doctrine in version 2.4.7 and Propel in version 2.0. At this point, I must strongly emphasize thatthis article is not to indicate which ORM is better

The Easiest ERD + ORM Integration Ever: Vertabelo and jOOQ

What is jOOQ? jOOQ, which stands for “jOOQ Object Oriented Querying,” is an ORM (object-relational mapping) for Java. With jOOQ you don’t write statements with “SQL-like language”; like Hibernate’s HQL. Instead, you write well designed and intuitive DSL code which, for someone speaking SQL, is obvious and self-explanatory. Read more » Some time ago I announced that the integration of Vertabelo and jOOQ was coming soon. While we’re waiting for an official (stable)

How to Develop a PHP+MySQL Application With Propel and Vertabelo

Propel is a popular ORM (Object-Relational Mapping) library for PHP. Recently, the Vertabelo team started to develop VertabeloPropel , a tool which converts your Vertabelo models into Propel’s schema xml.If you want to try using Propel with Vertabelo to develop a simple PHP MySQL application, here is how to do it. The following example uses Composer , a PHP tool for handling project dependencies.Set up Your ProjectCreate the file composer.json which describes your project dependencies. You will use at least Propel (package propel/propel) and VertabeloPropel (vertabelo/vertabelo-propel) as your project dependencies.

Visual Design of SQLAlchemy Models in 6 Steps

In this article I’m going to show you how to design SQLAlchemy models using Vertabelo , an online tool for visual database design, and our code generator.SQLAlchemy is propably the most advanced and well engineered OR/M for Python, while Vertabelo is a database design tool that works in a web browser. The Vertabelo code generator is an pythonic script called vertabelo-sqlalchemy . As you can see, the script is open source and hosted on

How to Generate Propel’s Schema.xml File From a Database Model Created in Vertabelo

If you use Propel, you can now generate a Propel schema file from a database model created in Vertabelo. Propel is a popular ORM (Object-Relational Mapping) library for PHP. In Propel, the datamodel structure is described by a special schema XML file. From this schema Propel generates PHP object model classes which Propel uses to represent rows in your tables. VertabeloPropel is a PHP script which converts a Vertabelo XML file into Propel’s schema.xml file.

jOOQ – A Really Nice Alternative to Hibernate

In the Java world, there are many standards. Some of them have grown up from commonly used libraries or frameworks. For example, JPA, which was highly influenced by Hibernate.Standards are good. They eliminate chaos and bad practices. But standards shouldn’t be a kind of Bible for developers. A set of tools used in the project should be chosen consciously, not blindly “because it’s a standard and others use it.” It’s like in the business market, where a monopoly causes a lot more harm than good.