How to set a default entity property value with Hibernate

If you want a real database default value, use columnDefinition: @Column(name = “myColumn”, nullable = false, columnDefinition = “int default 100”) Notice that the string in columnDefinition is database dependent. Also if you choose this option, you have to use dynamic-insert, so Hibernate doesn’t include columns with null values on insert. Otherwise talking about default … Read more

What’s the difference between JPA and Spring Data JPA?

I saw Spring, JPA works around repositories (DAO layer: if I am not wrong). So I mean how it is different using ‘Spring JPA + Hibernate’ or only using ‘Hibernate’ directly? As you said, JPA is an specification while Hibernate is a particular implementation of that specification (these implementations are usually referred to as Providers). … Read more

What is the difference between Unidirectional and Bidirectional JPA and Hibernate associations?

The main differenece is that bidirectional relationship provides navigational access in both directions, so that you can access the other side without explicit queries. Also it allows you to apply cascading options to both directions. Note that navigational access is not always good, especially for “one-to-very-many” and “many-to-very-many” relationships. Imagine a Group that contains thousands … Read more

Get the Query Executed in Laravel 3/4

Laravel 4+ Note for Laravel 5 users: You’ll need to call DB::enableQueryLog() before executing the query. Either just above the line that runs the query or inside a middleware. In Laravel 4 and later, you have to call DB::getQueryLog() to get all ran queries. $queries = DB::getQueryLog(); $last_query = end($queries); Or you can download a … Read more

What is choice_set in this Django app tutorial?

You created a foreign key on Choice which relates each one to a Question. So, each Choice explicitly has a question field, which you declared in the model. Django’s ORM follows the relationship backwards from Question too, automatically generating a field on each instance called foo_set where Foo is the model with a ForeignKey field … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)