I have an application using Tomcat/Spring 3/JPA/Hibernate but my merges do not commit to
datbase. This is the configuration:
spring-conf.xml:
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jd...
Hi I have a problem fetching the skills from the volunteer. for some reason i dont get the list when using this method
public Volunteer getVolunteer(int id){
Volunteer vo;
Query q;
q = em.createNamedQuery("Volunteer.findById").setParameter("id", id);
vo = (Volunteer) q.getSingleResult();
for(Skill s: vo.getSkills()){
System.o...
I use Hibernate for JPA DB mapping with Derby DB. For a complex object structure I am getting "org.apache.derby.client.am.SqlException: SELECT statement has too many items in GROUP BY, ORDER BY or select list":
org.apache.derby.client.am.SqlException: SELECT statement has too many items in GROUP BY, ORDER BY or select list.
org....
I currently have a mapping problem and no idea how to solve it. Here is what we currently have.
AbstractEntity is a @MappedSuperclass
ExtendedEntity is an abstract @Entity extending AbstractEntity with InheritanceType.TABLE_PER_CLASS
Proposal is a subclass of ExtendedEntity that has been stored in a single table so far.
Now I want to...
@Entity
public class Person {
@ElementCollection
private List<Location> locations;
[...]
}
@Embeddable
public class Location {
private Integer dummy;
private Date creationDate;
[...]
}
Given the following structure, I'd like to perform the HQL or CriteriaQu...
Hi all,
I wanted to know if there is a way to get in a One2Many relationship a field of the One side that is an aggregate of the Many side.
Let's take the following example:
@Entity
public class A {
@Id
private Long id;
@OneToMany (mappedBy="parentA")
private Collection<B> allBs;
// Here I don't know how to Map the latest B by d...
I'm working on a application that needs to do some database operations.
I created a static variable for EntityManagerFactory and Intialized it in the method that gets called by the application
if (emf == null){
emf = Persistence.createEntityManagerFactory("example");
}
try {
em = emf.cr...
I use Netbeans as IDE and use the wizards to generate Entities. If I want to define custom NamedQueries (not the ones auto generated) how can I define those outside of the entity so I don't lose them if I have to recreate the entity using the wizard?
...
@Entity
public class MUser implements Serializable, MemoEntity {
private static final long serialVersionUID = 1L;
@Id
private String email;
@OneToMany(cascade=CascadeType.ALL, orphanRemoval=true)
private Set<Meaning> mengs = new HashSet<Meaning>();
Shouldn't this mean that I get the constraint with a "on delete cascade"?
This is wha...
I've JPA entities and need to perform logic with them. Until now a huge static database class did the job. It's ugly because every public interface method had an private equivalent that used the EntityManager, to perform transactions. But I could solve that having a static em too!
However i'm wondering if that's an appropriate design, es...
Suppose I have a class 'Cheese' with fields type and purchaseDate, such that:
public class Cheese{
CheeseType cheeseType;
String purchaseDate;
public setPurchaseDate(String value){
purchaseDate=value;
}
public Class CheeseType{
String type;
public setType(String value){
type=value;
...
Does JPA support embedding a class attribute whose type is a parameterized generic or java.lang.Object? For example:
public class Foo<T>;
{
private T param1;
private Object param2;
}
I have a use case where I have a class that "wraps" some arbitrary class (the generic T or java.lang.Object) via aggregation plus contains pr...
Using JPA, can we define an enum as id of an entity?
I've tried the following:
public enum AssetType {
....
}
@Entity
@IdClass(AssetType.class)
public class Adkeys {
private AssetType type;
@Id
@Enumerated(EnumType.STRING)
@Column(nullable = false)
public AssetType getType() {
return type;
}
}
Using Ope...
I have following model:
Report,
ReportSection and
ReportSectionProperty.
Report has zero to many ReportSections, ReportSection has zero to many ReportSectionPropert-ies. This would qualifie as three levels deep object graph.
I create new Report, then add some sections to it, then add some properties to it. When I try to persist Report...
hi, I get this hibernate error(in the title), when I turn off the cascading(Cascade.ALL) and start to manually em.persist() the lower-in-the-hierarchy entities. So this is not possible at all?
I'm sure that the entities are persistent before, they are even in the database, but I get this error.
How to fix it?
EDIT:
java.lang.IllegalStat...
Hi, how can I force the EJB to not flush everything after every single command, I want to do a transaction. I've read that this is done somehow declaratively. But how exactly?
@Stateless
public class SomeBean{
@PersistenceContext
EntityManager em;
public void doSomeStuffAndThenFlushToTheDb(){
em.persist(entity);
// it's flushed ...
This seems like it should be a pretty simple question, or at least have a simple answer. But - I'm really not a database guy, and I'm still pretty far down on the Hibernate learning curve. That said, here's the setup:
Consider a unidirectional many-to-many relationship between two entities, from Foo to Bar:
(pardon any typos below, th...
hi, consider hibernate-link and JTA as peristence provider. How can I force em not to flush anything, and to handle it by myself?
@Stateless
public class SomeBean{
@PersistenceContext
EntityManager em;
public void method(){
em.persist(entity); // will get managed
em.clear(); // everything gets unmanaged
}
}
I would ex...
Anybody has an idea why adding the annotation-driven declaration leads to the aopalliance classes not found. I have not explicitly defined the weaving so using Spring defaults.
Any help is appreciated
...
Given:
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="postType", discriminatorType=DiscriminatorType.STRING)
public class Post {}
@DiscriminatorValue(value = PostType.BUG)
public class BugReport extends Post {}
That is ... Bugs start life in this system as a Post. Later, they can be promoted(?) to bei...