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...
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...
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?
...
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...
Is there a way to load only selected entities with Hibernate?
I would like to only load a selected handful for integration testing.
...
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...
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...
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...
Is there a way to specify which index to use, in HQL, to retrieve values from a MySQL table that has an index defined?
...
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...
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...
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...
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 ...
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...
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...
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...
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...
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...
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?
...
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 ...