I have 2 entities: car and wheels (oneToMany) and I want to retrieve my car, with all the wheels and (this is the tricky part) ordered by wheels.location.
Select c from Car LEFT JOIN FETCH c.wheels order by c.wheels.location doesn't work:
"illegal attempt to dereference collection".
Any idea how to do this and if this is possible in HQ...
I am working on medium sized web application 4-5 tabs, user login for about 100k users. We are completing redesigning the application from scratch and using spring and hibernate, connected to MySQL.
Did you experience major issues and what where did Spring benefit your application.
...
Hi,
I've got 2 entities in JPA: Entry and Comment. Entry contains two collections of Comment objects.
@Entity
public class Entry {
...
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@IndexColumn(base = 1, name = "dnr")
private List<Comment> descriptionComments = new ArrayList<Comment>();
@OneToMany(fetch = FetchTy...
I have a Book model and Inventory model mapped by ISBN number, but ISBN is not the primary key in either. Books belong to Bookstores and Inventory is for a group of Bookstores(BookstoreChain). Inventory is shared by all Bookstores belonging to a BookstoreChain.
I'm using Hibernate @OneToOne mapping on the book side to fetch inventory i...
I have a struts application that uses Hibernate to access a MYSQL DB. I have a number of pages that make changes to the DB. These changes go through fine, data is update in the DB. However when browsing to the page that should show this updated information its often not there, and even after a few page refreshes it still isn't there. Eve...
I am writing a Hibernate CompositeUserType, and in order to serialize the custom object to JDBC, I need to know the name of the table I am updating (because there is some configuration for my tool attached to the table).
The only way I can make this work right now, is to explicitly parameterize my UserType with the entity tablename, wh...
For this question, we want to avoid having to write a special query since the query would have to be different across multiple databases. Using only hibernate criteria, we want to be able to escape special characters.
This situation is the reason for needing the ability to escape special characters:
Assume that we have table 'foo' in ...
When deploying applications, I often use Hibernate’s capacity to create database schema in order to simplify the deployment. This is easily achievable by configuring hibernate.hbm2ddl.auto property.
However, on occasion I also need to insert some initial data to database, for example root user. Is there a way I could achieve this via h...
Hi,
I'm using Hibernate's JPA impl to model some tables. I'm having trouble mapping a table that:
Has no primary key
Has a unique index on 4 columns, 3 of which can be nullable
I tried to hack it and define the index as a composite Id, but since some columns are nullable this is not working properly. Is this possible with JPA/Hibern...
The following grails script:
// Import.groovy
includeTargets << grailsScript("Bootstrap")
target(main: "Import some data...") {
depends(bootstrap)
def Channel = grailsApp.classLoader.loadClass("content.Channel")
def c
// works: saving a valid Channel succeeds
c = Channel.newInstance(title:"A Channel", slug:"a-c...
I have two entities:
@Entity
public class Customer implements java.io.Serializable {
...
@OneToMany(fetch=FetchType.EAGER, mappedBy="customer")
private Set<CustomerOrder> customerOrders;
...
@Entity
public class CustomerOrder implements java.io.Serializable {
....
private double cost;
@ManyToOne
@JoinCo...
I've got a pretty ordinary JEE application running on JBOSS.
It uses the JBoss DatabaseLoginModule JAAS authentication.
It also has application layer users/roles in Hibernate that are exactly the same.
I've got an idea ( which I think is pretty useful for me, anyway) to have a capability bit I can set in the software license object (not...
Hi all,
I'm in process of migrating an old "classic ASP" application to J2EE/Hibernate.
I have a problem with the following type of SQL statements:
SELECT parent.id, parent.name, parent.column1, count(child.id) AS no_of_children
FROM parent
INNER JOIN child ON child.parent_id = parent.id
GROUP BY parent.id, parent.name, parent.column...
I was having a performance issue with a query Hibernate was creating due to too many fields being added from multiple joins. Hibernate seems to add all fields from joined tables to the select portion and I haven't figured out how to get it not to without property projections.
So I switch the query (using Criteria object) to use property ...
Hibernate is continuing to spew SQL traces to stdout, and I can't figure out how to change a Hibernate configuration property when it's hidden behind a JPA adapter. This is the Spring bean for the entityManagerFactory:
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<...
If I do the following
session.getTransaction().rollback();
is it then ok/possible to start calling save/update/delete etc. on the same session object? Couldnt find the answer to this in the Hibernate Session/Transaction API, or in the Hibernate reference documentation.
Or do you recommend me to close that Session object, open a new S...
Hi,
I'm trying to use an enum as a mapkey for a map in Hibernate, but Hibernate stores my enum as a RAW:
I have this enum:
public enum AccountType implements Serializable {
CASH,
CREDIT_CARD,
GIRO,
INVOICE,
OTHER;
}
Which I'm trying to use as a key in a map:
@CollectionOfElements
@MapKey(columns = @Column(name=...
I'v encountered a somewhat frustating problem.
Im using Apache Felix as my OSGi framework and Im also using Hibernate for persistency issues.
Im using the "osgi-bundle" version of Hibernate (com.springsource.org.hibernate-3.2.6.ga.jar). As far as I know this is the Hibernate Core with some additional osgi-metdata installed in the META-...
i am using hibernate annotations, at the back end i am using Postgres SQL 8.3. So, i don't know how to apply sequence in annotations of my Class.
Plz provide related help for this.
...
Hi,
Imagine I have a database with one table, this table has only one field named "word" and some other data, imagine also that user can search data by typing contents of this field. I have a lot of words on this table with Spanish accents.
Word examples
ácido
autobús
camión
Question
If user searches for "acido" or "ácido" words t...