What are some good Python ORM solutions? [closed]

If you’re looking for lightweight and are already familiar with django-style declarative models, check out peewee: https://github.com/coleifer/peewee Example: import datetime from peewee import * class Blog(Model): name = CharField() class Entry(Model): blog = ForeignKeyField(Blog) title = CharField() body = TextField() pub_date = DateTimeField(default=datetime.datetime.now) # query it like django Entry.filter(blog__name=”Some great blog”) # or programmatically for … Read more

Django queries – id vs pk

It doesn’t matter. pk is more independent from the actual primary key field i.e. you don’t need to care whether the primary key field is called id or object_id or whatever. It also provides more consistency if you have models with different primary key fields.

How to fix org.hibernate.LazyInitializationException – could not initialize proxy – no Session

If you using Spring mark the class as @Transactional, then Spring will handle session management. @Transactional public class MyClass { … } By using @Transactional, many important aspects such as transaction propagation are handled automatically. In this case if another transactional method is called the method will have the option of joining the ongoing transaction … Read more

Hibernate throws org.hibernate.AnnotationException: No identifier specified for entity: com..domain.idea.MAE_MFEView

You are missing a field annotated with @Id. Each @Entity needs an @Id – this is the primary key in the database. If you don’t want your entity to be persisted in a separate table, but rather be a part of other entities, you can use @Embeddable instead of @Entity. If you want simply a … Read more

Good PHP ORM Library?

Look into Doctrine. Doctrine 1.2 implements Active Record. Doctrine 2+ is a DataMapper ORM. Also, check out Xyster. It’s based on the Data Mapper pattern. Also, take a look at DataMapper vs. Active Record.

Add a custom attribute to a Laravel / Eloquent model on load?

The problem is caused by the fact that the Model‘s toArray() method ignores any accessors which do not directly relate to a column in the underlying table. As Taylor Otwell mentioned here, “This is intentional and for performance reasons.” However there is an easy way to achieve this: class EventSession extends Eloquent { protected $table=”sessions”; … Read more

Using an ORM or plain SQL? [closed]

Speaking as someone who spent quite a bit of time working with JPA (Java Persistence API, basically the standardized ORM API for Java/J2EE/EJB), which includes Hibernate, EclipseLink, Toplink, OpenJPA and others, I’ll share some of my observations. ORMs are not fast. They can be adequate and most of the time adequate is OK but in … Read more

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

I’ve opened a similar question in the Doctrine user mailing list and got a really simple answer; consider the many to many relation as an entity itself, and then you realize you have 3 objects, linked between them with a one-to-many and many-to-one relation. http://groups.google.com/group/doctrine-user/browse_thread/thread/d1d87c96052e76f7/436b896e83c10868#436b896e83c10868 Once a relation has data, it’s no more a relation … Read more

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