Question « Update « JPA Q&A





1. Hibernate Save Object Question    stackoverflow.com

I have these class :

@Entity
@Table(name = "branch", uniqueConstraints = {@UniqueConstraint(columnNames = {"bname", "branch_fk"})})
public class BranchEntity implements Serializable {

    @Id
    @GeneratedValue
    private int ...

2. Java persistence Question    stackoverflow.com

Hi I am new to Java persistence. Does it matter where I put the Annotations at? Are the following two sets of the code the same? Thanks a lot!!

@Entity
@Table(name="user", schema="billing")
public class User ...

3. Hibernate Stupid Question? Update persistent object    stackoverflow.com

I have a little question. I need to update an Object. I fetch it. The object is a Presistent Object. Now.. If I change any properties, because is a presistent (not ...

4. Question about saving data to sql database    stackoverflow.com

I am trying to add data to a sql database by entering info in text boxes and clicking a submit button. However, I cant get the submit button to work right. ...

5. Hibernate question: persistent identity    coderanch.com

Hi Joseph, yes I can see how we can easily interpret that as saying that the PK is the exact memory address. But, what it really says is that it needs to guarantee that java identity "==" will return true if and only if pk of the object .equals() the pk of the record in the database. This is why you ...

6. Hibernate Update Question    coderanch.com

Here is the thing you have Query queryObject = getSession().createQuery(queryString); Man man=(Man)queryObject.list().get(0); Where is the Session opened, when is it closed and the transaction commited? Basically in Hibernate you open a Session, and start a transaction, you do some stuff, like in your case you query for a record then call a setter. At that point either session.flush() or committing the ...

7. Newbie Question--Hibernate will not persist    coderanch.com

Okay, first let me apologize for such a basic question.....but I am so new I am at a lost on how to fix this simple issue..... What I have done is created a MYSQL database with all the relationships. There are 3 Xref tables (Many to Many). One table uses a composite for the primary key. All the other tables are ...

8. hibernate persistence.xml question    coderanch.com

hi guys i have the following persistence.xml : org.hibernate.ejb.HibernatePersistence com.itzone.model.persistence.entities.UserInfo ...

9. Basic question and problem with saving one-to-many assoc.    forum.hibernate.org

Newbie Joined: Wed Jan 06, 2010 9:09 pm Posts: 14 Hi All, I've got a simple test case which is not working and I'd like to understand why. The parent class is a TravelTimeSegment, it has amongst other members a set of TravelTimeGPSPoints in a one-to-many association. When creating a new TravelTimeSegment object and a new associated TravelTimeGPSPoints I'd like both ...





10. beginner question update table    forum.hibernate.org

I'm a beginner and I don't figure how to update 2 simple tables: I have one table Person and the other Phone.The Person table has a name, a surname etc. The Phone table has a number and a description. Between the 2 tables is a one to many relation. A person has one or more phone numbers. I don't know how ...

11. Newbie question: How to set timeout for persisting object    forum.hibernate.org

SessionFactoryManager.init(JNDI_URL); SessionFactory sf = SessionFactoryManager.getInstance(JNDI_URL); Session session = sf.openSession(); session.clear(); session.setFlushMode(FlushMode.COMMIT); Transaction transaction = transaction = session.getTransaction(); transaction = session.beginTransaction(); ... Invoice reqInvoice = ...; ... session.save(reqInvoice); transaction.commit(); ...

12. Hibernate update question    forum.hibernate.org

Customer cust = CustomerDAO.loadCustomer(custId); cust.setSalesRevenue(10000); //we do not call ...

13. JPA with hibernate persist question    forum.hibernate.org

Hello I have an entities model of an object which holds in a many to one manner another object example: Object A{ @Id @GenericGenerator(name = "generator", strategy = "increment") @GeneratedValue(generator = "generator") private int ID; @column(name="ColName",unique=true) private String Name; @OneToMany(fetch = FetchType.LAZY, mappedBy = "objA") private List ObjsB = new List(); } Object B{ @Id @GenericGenerator(name = "generator", strategy = "increment") ...

14. Question about JPA and Persistence.xml    forum.hibernate.org

Hello, I am starting to use JPA 2 with Hibernate. Is it possible to set the connection information that is in the Persistence.xml file programmatically? In my case the connection parameters will be entered through the UI and will not be available at startup. If this possible how can I do this? If not, can I do this with Hibernate directly? ...

15. persisting data with saveOrUpdate() -- question    forum.hibernate.org

That didn't work, the code now looks like this: Code: protected void storeObject( Session ses, Object obj ) throws DAOException { try { ses.saveOrUpdate( obj ); ...

16. Update question    forum.hibernate.org

.. which may prove cumbersome for you as you may have multiple objects and thus need to iterate over all the objects. As far as I know, there isn't a method to bulk-kick all objects of a given class out of the session cache. Anyone else know of a method (besides closing the session)? Justin





17. Update Question    forum.hibernate.org

19. saveOrUpdate(Obj) question    forum.hibernate.org

saveOrUpdate uses your unsaved-value-strategy to determine if you entity is persistent or transient. If your whole goal is to always have your ID returned to you when persisting your objects, use saveOrUpdate but the immediately flush the session so the DML is actually sent to the DB. Then, you should be able to get the ID of the entity. Either way, ...

20. Question about updating an object    forum.hibernate.org

Hibernate version: 2.1.6 Name and version of the database you are using: Postgres My team and I are trying to decide b/w using hibernate or JDBC/SQL, one question we keep hitting upon, that I don't have an answer for yet, is about updating an object. Say I have an object A that has a one-to-many relationship with object B... If using ...

21. Question about saving objects    forum.hibernate.org

Hibernate version:2.1.2 Mapping documents: Person.hbm.xml cat Cat1.hbm.xml

22. [question] How to save multiple copies of an object?    forum.hibernate.org

I'm not sure if this is a completely trivial question, but I can't see how to do it, so asking here is my last resort. Apologies in advance if I'm simply missing something obvious. I have an application running on JBoss and developed in Struts. All the objects are saved in our mysql database with hibernate (using xdoclet to define the ...

23. Advanced question: Dirty Checking vs. SaveOrUpdate    forum.hibernate.org

Hi there everybody, i got the following problem in my application using Hibernate 2.1.7 in a Tomcat 5.0 w/ Java 5 and an Oracle 8i DB. i retrieve an business object (i.e. an Employee) and i change some properties on it. when i click on the save button i want a popup to open asking me wether i really want to ...

24. SaveOrUpdate question    forum.hibernate.org

When generator is assigned then saveOrUpdate will not work by very simple reason: According to mapping unsaved value is null, but when you assign id to something, then for saveOrUpdate it means that object exists and H needs to update it. But since there is no such object in the DB, the update count is 0 and H expects 1, hence ...

25. method saveOrUpdate() question    forum.hibernate.org

Hello EveryBody: I found a problem that i can not solve it, i hope everybody can helpme: I have a Object that contains a "CompisteId". Wu assume that object be called "ObjectX", and his CompiseteId is called like XId. class ObjectX{ private Xid xid; private String toUpdateOrSave; } class Xid{ private int id1; private int id2; private int id3; public boolean ...

26. Persistence class Question    forum.hibernate.org

27. Hibernate saving single and double quotes as question marks    forum.hibernate.org

I'm having a problem with Hibernate where is saving single and double quotes as question marks. I debug the application and see the string to be saved just before a Hibernate "this.save(content);" A sample string to be saved is as follows: Lorem Ipsum 'is simply dummy' text of the "printing" and typesetting industry. Lorem Ipsum has been the industry's standard dummy ...

28. Hibernate many-to-one save question    forum.hibernate.org

I need to implement a function private void saveChild(Integer parentId) { //save a child object to the DB that has Child.parent.id = parentId; } As far as I know, the way to do this is to create the Child and Parent objects, and then to call the Session.save() function, passing in the child object. Below is a sample mapping file for ...

29. Object saving question    forum.hibernate.org

Hi, I have a little doubt. Suppose I have a Question class and I do this: ****************** Question q = new Question(); q.setText("question1"); getSession.save(q); ******************* that should persist the question in the db. then in another moment(session) I repeat the same thing. Then in my DB i get: id text 1 question1 2 question1 BUT I want to get: id text ...

30. Hibernate SaveorUpdate Question    forum.hibernate.org

Newbie Joined: Tue Apr 15, 2008 4:56 am Posts: 5 Hi Everyone, I am facing a problem with updating database table row. When I am trying it with saveorupdate, it inserts a new value into the table rather than updating. Can anyone please help with this. Hibernate version: 3.2.4 Mapping documents: CoursePlan.hbm.xml:

31. question about persisting many-to-one objecs    forum.hibernate.org

Hi, I am using Hibernate 3.x with MySql 5.0. Is the 6th line necessary here? Do we need to execute manufactureDAO.saveManufacture(manufacture); here ? 1. @Transactional(propagation = Propagation.REQUIRED) 2. public void saveProduct(final Product product, final Integer manufacturerId) 3. { 4. Manufacturer manufacturer = manufacturerDAO.loadManufacturer(manufacturerId); 5. product.setManufacturedBy(manufacturer); 6. manufacturer.addProduct(product); 7. productDAO.saveProduct(product); 8. } Mapping Files =============

32. update question    forum.hibernate.org

Hi, ive mapped this class: Code: class myclass { private integer id; private integer left ; private integer right ; public myclass() {} //here only getter for the fields getleft, getright, getid. } via field injection. a service passes instances of this class to the frontend and i dont want the frontend to be able to modify those properties. now i ...

34. Question on Update() method    forum.hibernate.org

The update() method is for reattaching detached objects, in your mind you could rename it to reattach(). :) This method will always schedule an update, regardless of the object being modified or not. If you don't want to force an update statement, use the lock() method instead, as in anotherSession.lock(testObject, LockMode.NONE); LockMode.NONE tells Hibernate to not perform a version check. With ...

35. one to many persist question    forum.hibernate.org

Hi All, I have a classic one to many persist problem. Bellow are my entities: Parent class ======== @Id @GeneratedValue(strategy = SEQUENCE, generator = "seq_idP") private long idP; @OneToMany(mappedBy = "idPChildren", cascade = { CascadeType.ALL }, fetch = EAGER) private List childrenCollection; Children class ========= @EmbeddedId private ChildrenPK pk; @ManyToOne @JoinColumn(name = "idP", referencedColumnName = "idP", insertable = false, updatable = ...

36. Newbie question - "Java Persistence with Hibernate"    forum.hibernate.org

I'm reading "Java Persistence with Hibernate", Chapter 2. I'm trying to run the examples in Eclipse development environment(Ganymede), using the JBOSS plug-in server and Hibernate. I'm stuck on the example which runs EJB components with JBOSS (page 115). I have downloaded the source code from http://www.manning.com/bauer2/ . The persistence.xml and helloworld-beans.xml I have put in the META-INF directory of my project. ...