Questions tagged [orm]

Object-relational mapping (ORM) is a technique for mapping object-oriented systems to relational databases. Use other tags to indicate the programming language ([java], [sql], [python]), database system ([postgreSQL], content management system ([django]), framework ([flask], [spring], [laravel]), application environment ([android], [node.js]), and other tags that can be used for searches and have watchers.

Object-Relational Mapping

Object-Relational Mapping (ORM) is a technique for mapping object-oriented systems to relational databases. This creates, in effect, a "virtual object database" that can be used from within the programming language. There are both free and commercial packages available that perform object-relational mapping.

Resources

Related tags

17748 questions
1795
votes
18 answers

What is the "N+1 selects problem" in ORM (Object-Relational Mapping)?

The "N+1 selects problem" is generally stated as a problem in Object-Relational mapping (ORM) discussions, and I understand that it has something to do with having to make a lot of database queries for something that seems simple in the object…
Lars A. Brekken
  • 20,385
  • 3
  • 23
  • 27
698
votes
31 answers

How to fix the Hibernate "object references an unsaved transient instance - save the transient instance before flushing" error

I receive following error when I save the object using Hibernate object references an unsaved transient instance - save the transient instance before flushing
Tushar Ahirrao
  • 10,773
  • 16
  • 61
  • 95
680
votes
22 answers

What's the difference between JPA and Hibernate?

I understand that JPA 2 is a specification and Hibernate is a tool for ORM. Also, I understand that Hibernate has more features than JPA 2. But from a practical point of view, what really is the difference? I have experience using iBatis and now…
Anthony
  • 27,490
  • 32
  • 129
  • 238
609
votes
16 answers

Difference between FetchType LAZY and EAGER in Java Persistence API?

I am a newbie to Java Persistence API and Hibernate. What is the difference between FetchType.LAZY and FetchType.EAGER in Java Persistence API?
leon
  • 8,725
  • 18
  • 57
  • 73
557
votes
8 answers

JPA JoinColumn vs mappedBy

What is the difference between: @Entity public class Company { @OneToMany(cascade = CascadeType.ALL , fetch = FetchType.LAZY) @JoinColumn(name = "companyIdRef", referencedColumnName = "companyId") private List branches; …
Mike
  • 17,033
  • 22
  • 85
  • 113
468
votes
27 answers

Infinite Recursion with Jackson JSON and Hibernate JPA issue

When trying to convert a JPA object that has a bi-directional association into JSON, I keep getting org.codehaus.jackson.map.JsonMappingException: Infinite recursion (StackOverflowError) All I found is this thread which basically concludes with…
Ta Sas
  • 8,699
  • 15
  • 45
  • 72
431
votes
31 answers

How to print a query string with parameter values when using Hibernate

Is it possible in Hibernate to print generated SQL queries with real values instead of question marks? How would you suggest to print queries with real values if it is not possible with Hibernate API?
craftsman
  • 13,785
  • 17
  • 61
  • 82
412
votes
5 answers

Hibernate show real SQL

if I set true in my hibernate.cfg.xml configuration file in the console I can see the SQL. But it's not real SQL... Can I see the SQL code that will be passed directly to database? Example: I see select…
Tommaso Taruffi
  • 8,462
  • 9
  • 40
  • 54
400
votes
26 answers

Conversion of a datetime2 data type to a datetime data type results out-of-range value

I've got a datatable with 5 columns, where a row is being filled with data then saved to the database via a transaction. While saving, an error is returned: The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range…
Gerbrand
  • 4,724
  • 4
  • 27
  • 34
360
votes
7 answers

What's the best strategy for unit-testing database-driven applications?

I work with a lot of web applications that are driven by databases of varying complexity on the backend. Typically, there's an ORM layer separate from the business and presentation logic. This makes unit-testing the business logic fairly…
friedo
  • 62,644
  • 16
  • 111
  • 180
356
votes
15 answers

Default value in Doctrine

How do I set a default value in Doctrine 2?
Jiew Meng
  • 74,635
  • 166
  • 442
  • 756
333
votes
4 answers

Which ORM should I use for Node.js and MySQL?

I'm rewriting a project to use Node.js. I'd like to keep using MySQL as the DB (even though I don't mind rewriting the schema). I'm looking for a simple-to-use, reasonable-performance ORM, which supports caching, many-to-one and many-to-many…
Near Privman
  • 3,640
  • 2
  • 14
  • 11
289
votes
15 answers

Any good ORM tools for Android development?

Anyone working on the Android ('gPhone') have or know of a place where I can find a good ORM tool for it? The code is written in Java, and the database is SQLite. What I would like to find is a tool that given the object definition, can…
GWLlosa
  • 22,656
  • 17
  • 75
  • 108
288
votes
14 answers

Doctrine2: Best way to handle many-to-many with extra columns in reference table

I'm wondering what's the best, the cleanest and the most simply way to work with many-to-many relations in Doctrine2. Let's assume that we've got an album like Master of Puppets by Metallica with several tracks. But please note the fact that one…
Crozin
  • 41,538
  • 12
  • 84
  • 134
278
votes
6 answers

Entity Framework Code First - two Foreign Keys from same table

I've just started using EF code first, so I'm a total beginner in this topic. I wanted to create relations between Teams and Matches: 1 match = 2 teams (home, guest) and result. I thought it's easy to create such a model, so I started…
Jarek
  • 5,447
  • 6
  • 38
  • 54
1
2 3
99 100