I use 2 separate database, so i have to use JTA to handle distributed transactions.So either either both db have to commit or both rollback. I use open JPA and JTA.Now to unit test the code using junit ? I get the following error when i try to run my code which handles distributed transcations.I had posted similar question on this sit...
Hi, I have a problem with Hibernate generating an SQL that do not work on SQLServer (works on PostgreSQL without any problems). I have tried to set the hibernate dialect for SQLServer but the same SQL is still generated and still do not work. The HQL query looks like this:
select count(t) from ValidationLog t
The generated SQL looks ...
We would like to orderBy 2 columns in the Seam EntityQuery interface as well as the JPA model. How do we do this?
@Entity
public class A{
@OrderBy(???) // should this be hardcoded here, is it database agnostic
List<B> bobjects;
}
@Entity
public class B {
public short startTimeHrs;
public short startTimeMins;
}
@Name("bList")
p...
Hi all.
We have a project with some special requirements, one of wich is getting data from a XMLType database column from an Oracle 10g database.
We have found an easy solution using JDBC, but it would drive the application a little messy, as all the data access is being done through JPA (the implementation used is EclipseLink).
We ha...
Hello,
I'm trying to move some old code from hand-made persistence to Hibernate. The issue here is a peculiar mapping where the target entity type/table is defined by a column value.
Example database table:
Table "Relation":
id - my primary key
parentType - a char that specifies the type of parent (e.g. 'I' meaning an object in the ...
When we have a class:
@Entity
Order implements Serializable {
@Id
private Integer id;
...
}
and:
@Entity
OrderLine implements Serializable {
@Id
private Integer id;
@ManyToOne
Order order;
...
}
What row name will the property order map to?
order_id, ORDER_ID or Order_id?
(ommiting the @JoinColumn...
Can you tell me when to use it and why should I create a new table just for keeping primary key while most DBMS now support auto increment and you can adjust it easily?
...
If there is a null value stored in a MySQL INT column, it will return 0 when accessed by technoligies like JPA. If 0 value also stored in the column, how can I differentiate between null and 0?
...
Hi,
I have a DAO where I need to catch an unique constraint exception. To do this, the only working solution is to flush my EntityManager after the persist. Only then I come into a catch block where I have to filter out the exception. And, my DAO method needs to be wrapped in a transaction (REQUIRES_NEW) otherwise I have the RollBackExc...
Hi,
I have a whole bunch of Java beans annotated like this with JPA:
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class TitleEntry extends Entry
{
private Long id;
public TitleEntry() {}
public TitleEntry(St...
Suppose I have a Post entity and a Comment entity and a one to many relationship:
@Entity class Post {
...
@OneToMany
List<Comment> comments;
...
}
How can I achieve paging like this:
Post post = //Find the post.
return post.getComments().fetch(100, 10); // Find the 11th page (page size 10);
Is it possible to emulat...
I need to use java.util.Calendar in order for Axis2 webservice client to send/receive Date objects. So in my JPA model object I changed all java.sql.Date into java.util.Calendar. By using java.util.Calendar the Axis2 webservice part work ok.
I'm able to save a java.util.Calendar object into database. Problem is that I can not read th...
I'm working on a project which uses JPA for persistence, and I'm trying to find the cleanest and most efficient means for testing JPQL queries. I am more accustomed to the Hibernate world... in which you can test HQL on an ad hoc basis outside the application, using Hibernate Tools and its Hibernate Console. I believe that tool also su...
I want to implement the state design pattern in JPA. The way I am currently doing this is outlined in this blog post.
The author uses an enum containing all available state implementations instead of creating abstract class/interface for state abstraction and writing implementation for each state. I find this approach very useful, since...
Let's say I have methods with following signature
Object getData(int id) {
//create a entity manager
//get data frm db
//return data
}
updateData() {
Object obj = getData(id)
//get entity manager
//start transcation tx
//update
//commit tx
}
Now will it cause concurrency issue? Can data be stale in worst case? E.g....
Hi All,
I want to know whether I can join 2 named queries in JPA. As an example I have two following named queries
1 - Get all the active users
2 - get all the users for a given company
Is it possible for me to join above two named queries and get
get all the active users for a given company.
If possible pls send me some reference...
Hi,
I want to avoid serialisation ( in JMS / AMF ) but still persist the field with JPA/Hibernate.
Is the transient modifier my friend ? Are @Transient annotation and the transient modifier related or not a all ?
The java specification precise that a transient field will not be saved to a persistent storage by a system service. But is...
class decalaration:
@Stateless
@Local( { IMyLocalSLSB.class })
@Remote( { IMyRemoteSLSB.class }) })
public class mySLSB implements IMySLSB {
private EntityManager em;
and now some methods for inserting/updating and deleting db records are transactions annotations required, I thought they were not as jboss and EJB3.0 handle them using...
Greetings earthlings,
For production we are using a Oracle database with some fancy stuff for IDs
@Id
@GeneratedValue(generator = "generator")
@GenericGenerator(name = "generator", strategy = "guid", parameters = {})
@Column(name="PROPERTY_ID")
private String propertyId;
For testing I thought I'd just use a H2 in memory database and ...
Hi all,
Thought I would try out Spring Roo so I've had loads of new fun problems today. Hopefully you guys can help me with latest one. Roo has the ability to generate integration tests for your entities, but most of them fail for me. The most common failure is some form of constraint violation like null is being inserted into non-null ...