orm

IntegrityError: (1062, "Duplicate entry '1830327-1792993' for key 'some_instance_A_id'") but no UNIQUE constraint

I'm rarely getting such exception when adding model instance to many2many field, i.e.: some_instance_A.my_m2m.add(some_instance_B)). It works say 99/100 times. What looks strange to me, is that dash sign - as primary keys are integers.. Model field is defined like this: my_m2m = ManyToManyField(B) so it's the simplest M2M defi...

Telerik OpenAccess ORM - Is anyone using it?

I'm working on a new project right now and am thinking of using an ORM beyond that of Linq to SQL. I've currently got Linq to SQL wired up into a repository, but I'm not loving the way my Repo has to match my DB structure. (Example: I have a join between Users and OpenID's, and I need a 2 classes ( one for each table) and a class for t...

JSF, Hibernate and serving a BLOB

I want to serve an image saved as a blob in a MySQL Database through hibernate3 in a JSF application. My intention is that /myapp/image/get.faces?id=x will serve the image saved in the database with id x. How to achieve this? ...

Django - Count a subset of related models - Need to annotate count of active Coupons for each Item

I have a Coupon model that has some fields to define if it is active, and a custom manager which returns only live coupons. Coupon has an FK to Item. In a query on Item, I'm trying to annotate the number of active coupons available. However, the Count aggregate seems to be counting all coupons, not just the active ones. # models.py cla...

Loading selected Hibernate entities with JPA & Spring

Is there a way to load only selected entities with Hibernate? I would like to only load a selected handful for integration testing. ...

Can I refer to the primary key of any entity in JPQL by the name "id", regardless of the entity's ID property name?

Hibernate allows you to just say ".id". Let's say I have: @Entity public class Customer { @Id private Integer customerId; @Basic private String customerName; // getters and setters } And I want to get the name of a customer by ID: SELECT cust.customerName FROM Customer cust WHERE cust.id = :customerId Notice I put "id" rathe...

Migrating procedural, antique CRUD code and proprietary DBMS to OO ORM on SQL

Please excuse my long-winded explanation, but I wanted to be as explicit as possible in the hopes of getting as much useful feedback on my situation as possible. You can skip to the questions at the bottom if you are impatient. Explanation At my current job, development is done in an antiquated language that is hard-wired to a proprie...

how to get the attribute group in magento

Hi, I need to get the attribute group of a certain attribute set , how can i do this ? i think i got the attribute group id but i can't seem to get the attributes of that group. $attributes = $_product->getAttributes(); foreach($attributes as $attribute) { $group_id = $attribute->getData('attribute_set_info/' . $_pro...

Specifying index in HQL queries

Is there a way to specify which index to use, in HQL, to retrieve values from a MySQL table that has an index defined? ...

Hibernate auto increment field for multiple databases

Hello, I have a Java object with a field that needs to be auto-incremented in the database. This field is not a primary key, just a field that needs to be auto-incremented. My question is what value I need to set this field in my Java object before doing a session.save(Object)? Do I have to set it to NULL? How would the Hibernate mapp...

No response to Show and Rails Routes

I have my file structure set up appropriately ( I think ! ) , and claims nothing responds to show. My file structure : views/admin/admin_wysi/index.html.haml My controller ( controllers/admin/admin_wysis_controller.rb ) class Admin::AdminWysisController < Admin::ApplicationController def index end end My routes.rb map.name...

Applying an Index to a Blob/Longtext field

I am trying to create an index on a particular text string using Hibernate annotations. What I am currently doing is: @Index(name="guid_index") @Column(length=1400) private String myGUID; However, since the length of the column is 1400, this maps to SQL using the longtext type. hbm2ddl is able to create the table without mishap, but w...

JPA or Hibernate - Joining tables on columns of different types

Is there a way to tell Hibernate to wrap a column in a to_char when using it to join to another table or conversely convert a NUMBER to a VARCHAR? I have a situation where I have a table which contains a generic key column of type VARCHAR which stores the Id of another table which is a Number. I am getting a SQL exception when Hibernate ...

Search for a property in Hibernate after aplying a function.

In my db I store telephone numbers of things as input by the user (I want to let user decide how he format their phone number) when users search for a phone number they most likely wont format the number in a way that I can just compare the two strings. Even 'like' wont do the trick since maybe the number has parenthesis or some other u...

NHibernate: Simple way to treat default values as null (or vice versa)

Does anyone know of a quick way to have NHibernate insert default values for value types as null into the database? For example: public class Foo { public int SomeProperty { get; set; } } By default, int is 0. When it goes into the database, I would like it to go in as null. I know I could do this by changing SomeProperty to a nu...

Java - Should I use a field or a class for the problem as follows:

I have two tables in the DB FuelStation (fuel_station_id: int (PK), fuel_station_name: varchar, fuel_brand_id: int(FK)) FuelBrand (fuel_brand_id: int (PK), fuel_brand_name: varchar) As we can see, both tables are linked via. foreign key (fuel_brand_id) Now, I want to design an object model corresponding to the above data model but I...

Hibernate | Identifier Generation Exception

I'm getting an exception when I try to save some data through hibernate persistence layer, the exception is org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): hbm.Employee public void saveEmployee(Employee empValue) { Session session = null; Transaction t...

Should I use static of non-static sessions?

I've recently taken on the database/hibernate side of our project and am having terrible trouble understanding some fundamentals of our design regarding the use of managed sessions. We have a util class containing a static session that is only initialised once. Retrieval of the session is used by every DAO in the system via a static met...

about j2ee, spring and hibernate

Basically i want to learn this technology. I already know J2SE. My question is, where is the good start to learn Spring and Hibernate? Is the book Head First JSP and Servlets good or what? ...

Hibernate, SQL and recursive associations

My database has two tables, "question" and "field". Questions may have many fields, and fields may have many fields. It's a tree with a special root node. I want to use them with hibernate (currently potgresql) - so it should be straightforward and simple to use it from java. What is the best solution to this? add question_parent_id ...