MySQL « Map « JPA Q&A





1. Why does MyEclipse's Hibernate Reverse-engineering creates multiple classes when mapping certain tables?    stackoverflow.com

I have a table in my MYSQL database which does not have a primary key, but has a unique key on two columns. When using MyEclipse's Hibernate reverse engineer tool ...

2. Hibernate: How to make Hibernate delete records from child table when deleting parent if child is linked to parent with many-to-one?    stackoverflow.com

Lets say I have two tables - "child" and "parent" with many-to-one relation. What I need is to delete child entries if parent record is deleted. It is not a problem if ...

3. Help with Hibernate Collection Foreign Key Mapping    stackoverflow.com

I'm running into significant difficulty getting my mapping file to work with a collection of elements via a foreign key in Hibernate. Java will try to load these files below and ...

4. Hibernate one-to-one mapping problem    stackoverflow.com

Hello I've the following class:

public class Movimenti implements java.io.Serializable {

private Integer id = null;
private Integer idCommessa = null;
private String nomemovimento = null;
private Movimento preventivato = null;
private Movimento effettivo = null;

public Movimento ...

5. Simplest one-to-many Map case in Hibernate doesn't work in MySQL    stackoverflow.com

I think this is pretty much the simplest case for mapping a Map (that is, an associative array) of entities.

@Entity
@AccessType("field")
class Member {
    @Id
    protected long ...

6. What are the hibernate annotations used to persist a Map with an enumerated type as a key?    stackoverflow.com

I am having trouble getting the right hibernate annotations to use on a Map with an enumerated class as a key. Here is a simplified (and extremely contrived) example.

public class ...

7. Type mapping mysql typ text to java hibernate!    stackoverflow.com

What is the correct mapping type from MySql data type text to java using hibernate?

@Column(name = "STACKTRACE", length = Integer.MAX_VALUE)
public String getStacktrace() {
    return this.stacktrace;
}

8. How to create an @Entity with a parent/child relationship    stackoverflow.com

I am creating a website that will have articles; each article will have comments. These comments will be stored in a "comment" table with a field called "parent_id" that is a ...

9. hibernate map java Long to MySQL BIGINT error    stackoverflow.com

i have a table with id field type BIGINT in MySQL in hibernate object, i use java Long type for this field but when run program, it throw exception: Expected: class java.lang.Long, got class ...





10. Hibernate inheritance with existing tables    stackoverflow.com

I have 2 existing tables in my database. Let's call them Table and Chair for now. Both these tables are mapped as entities in Hibernate Both these tables have existed in my database for ...

11. How to create Id on hibernate entity that is a byte[] that maps to a varbinary value in mysql    stackoverflow.com

I am trying to create an Entity that has a byte[12] id in hibernate. It seems like it does not like to have a byte[] as a primary key and ...

12. Why do i have a mapping exception?    stackoverflow.com

Right now i want to make a small java application, in order to learn the hibernate framework. But it gives me the org.hibernate.MappingException: Repeated column in mapping for entity: model.Book column: ...

13. Mapping a byte[] that can grow up to 400KB on MySql    stackoverflow.com

I have the following:

@Entity
public class ExamplePhoto {

...

@Column(nullable= false)
private byte[] photo;

...
}
I am using Hibernate and a MySql database. I tried putting a mediumblob but got a "tinyblob expected error" message. Given the ...

14. Hibernate mapping object to table having a certain value?    stackoverflow.com

I have a table called Object that has a foreign key to ObjectType table. For my domain model, I have an object for each ObjectType: How do I map the domain ...

15. kick off a map reduce job from my java/mysql webapp    stackoverflow.com

I need a bit of archecture advice. I have a java based webapp, with a JPA based ORM backed onto a mysql relational database. Now, as part of the application I ...

16. Mapping a @Lob valued Map    stackoverflow.com

This is part of my model:

@Entity
public class Entry
{
    @Id @GeneratedValue
    private long identifier;

    @ElementCollection
    @Column(nullable = false)
   ...





17. org.springframework.orm.hibernate3.HibernateQueryException --HibernateTemplate problem    stackoverflow.com

I am having a problem with HibernateTemplate and I dont know where I am goin wrong. I am using Hibernate3 and Tomcat6. In my DAO, I have functions that try to query ...

18. hibernate column type problem (MySql)    stackoverflow.com


I am getting this exeption:
Can not set int field com.affiliates.hibernate.Employee.employeeId to java.lang.Integer
while tring to fetch results from creteria:

Transaction t = getSession().beginTransaction();

DetachedCriteria c = DetachedCriteria.forClass(Affiliate.class);
c.add(Restrictions.eq("employee", 1));
List l = c.getExecutableCriteria(getSession()).list();
t.commit();
running the query in ...

19. deleting mapping record when deleting either objects    stackoverflow.com

My application uses Java, Hibernate and MySQL The following defines mapping between the 2 entities 'chapter' and 'resource' in Resource.java:

// a chapter can have many resources but a resource can belong to ...

20. Many-to-Many hibernate mapping and mysql script - persistence problem    stackoverflow.com

For some reason this is not persisting anything into tag_item table :

    Tag tag = new Tag();
    tag.setName("test");
    tag = (Tag) tagService.save(tag);

 ...

21. JPA Entities - MySQL tables Mapping    stackoverflow.com

Database tables:

  1. Tutor( {PK}tutorId, name )
  2. Module( {PK}moduleId, name, {FK}tutorId )
Relationship Tutor -> Module (OneToMany) Questions:
  1. If you create the domain model classes with JPA annotations, the corresponding database tables are auto-created with the same columns as ...

22. @ManyToMany with Hibernate and JPA    stackoverflow.com

I have two tables that are bound by a ManyToMany relationship. Table 1 is TimeSlot and has a collection of documents created in that time slot. Table 2 is Documents and has ...

23. which solution is good practice hibernate save data in database?    stackoverflow.com

I have two entities which are Student and Class entities. Student and Class are many to one relationship. So student contains class attribute. Now i want to save or create a student ...

24. Java EE JPA 2 Entity Mappings    stackoverflow.com

I have a MySQL database with the following:

`title` text,
`content` longtext,
and have them mapped to the following Entity attributes:
private String title;
private String content;
Here are my questions:
  1. When entering a value, does the JPA ...

25. Hibernate configuration with mysql    stackoverflow.com

I'm trying to configure huibernate with mysql. following is the hibernate.cfg.xml:

<hibernate-configuration>
    <session-factory>

        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property ...

26. Mapping Hibernate to MySQL (BEGINNER)    stackoverflow.com

Is there a way to map an Entity class (Address.java) to MySQL without using Hibernate Mapping (.hbm files) What i need to do is to Create a table called 'Address' in the ...

27. MySQLSyntaxErrorException while using Hibernate ManyToMany annotation    stackoverflow.com

I have a problem with my @ManyToMany annotated hibernate class. Everything seems fine to me but i get MySQLSyntaxErrorException. I am sorry if it is a simple question. Let me summarize the logic.I have ...

28. SQL Error: 1064, SQLState: 42000:org.hibernate.exception.SQLGrammarException:    stackoverflow.com

I am trying to insert some data using hibernate but facing some issue while achieving this.i am using following configurations

-Hibernate 3.6.8
-MySQL 5.5.17
I am using org.hibernate.dialect.MySQL5InnoDBDialect as my dialect i have a DonorPofile ...

29. Java Hibernate Cascading Issue    stackoverflow.com

---- Introductionary information and problem domain ----


Basicly I have 3 tables in a database: 'User', 'Item', 'ItemsPerUser'.

Table User:

username (PK); password; email

Table Item

name (PK)

Table ItemsPerUser

username (PK) (and FK); item_name (PK) (and FK) When I don't ...

30. mysql LongText mapping in Hibernate    coderanch.com

I have a database field in a mysql db report_data which can contain a large amount of text data. I had been using the 'text' column datatype untill I ran into the limit recently. I've tried changing the column datatype to 'LongText' in the DB and updated the mapping file to ; But I ...

31. mysql BIGINT column mapping in hibernate    forum.hibernate.org

Hi, I am using MYSQL 5.1.36. The primary key of a table is BIGINT. The ID generation is using MYSQL auto_increment. This is the hibernate mapping configuration: Since I want to stick with what MYSQL jdbc driver recommend, using java.math.BigInteger for bigint column. Also that column is an ...

32. MySQL tinyint(3) unsigned being mapped to a Byte by hbm2hbmx    forum.hibernate.org

Hi All, I've generated the .hbm.xml mapping files from my mySQL database many times successfully. For some reason however, it's mapping a tinyint(3) unsigned (which can store 0..255) to a Java Byte, which is a signed data type. Are there any options I can tweak to make it generate a type which will hold the full 0..255? Thanks, Fred

33. How to map mysql set datatype    forum.hibernate.org

34. Mapping byte[] under MySQL    forum.hibernate.org

Hi, I am trying to map a "byte[]" property under Hibernate with MySQL running under the hood. I tried mapping the byte[] to type "blob" but I would get the following exception: java.lang.ClassCastException: [B net.sf.hibernate.type.BlobType.set(BlobType.java:27) net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48) net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35) net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.java:393) net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:527) net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432) net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29) net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:932) net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:857) net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:775) net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738) com.tog.desktopbeautifier.AddImage.processRequest(AddImage.java:79) com.tog.desktopbeautifier.AddImage.doGet(AddImage.java:110) javax.servlet.http.HttpServlet.service(HttpServlet.java:743) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) So then I mapped the property to "binary" and that worked except ...

35. byte[] mapping with MySQL and Hypersonic    forum.hibernate.org

I need to map a byte[] to a database column. This byte[] could contain zeros, so I use a BLOB. Code:

37. How to map MySql GEOMETRY to Hibernate?    forum.hibernate.org

38. Problem persisting child object - Hibernate3.0.5 and MySql    forum.hibernate.org

Hi, I was having a problem persisting a new child object using Hibernate 3.0.5 and MySql. I have two object TrainingTask and TrainingTaskRevision. A TrainingTask has many revisions. TrainingTask had a set of revisions and the revision had a one-many relationship back to the task. I mapped the TrainingTask with the inverse="true" attribute. The mappings were fine because I could retrieve ...

39. Map Set to MySql SET type    forum.hibernate.org

public enum E {E1, E2, E3;} /** * @hibernate.class */ public class Foo { /** * @hibernate.id */ private int id; /** * */ private Set eSet = new HashSet(); public Foo() {} }

40. Byte not mapping to MySQL tinyint properly    forum.hibernate.org

Hibernate is attempting to set a byte property to a non-byte value. (My colleague says she sees a boolean being used in a sql trace.) Is this a Hibernate bug? It seems that Hibernate should know the type of the argument to the set method and never attempt to set using non-byte data. The database field is tinyint, and the mapping ...

41. mapping to mySQL longblob    forum.hibernate.org

Hi, I'm using mySQL 5.0 with hibernate 3. I want to store binary data in a mySQL 'longblob' data type. As far as I can see there is no hibermate mapping for this. For example, I might have a mapping file like this: Which will create ...

42. Mapping into a Text field in MySQL    forum.hibernate.org

43. How to map MySQL Binary field in Entity class?    forum.hibernate.org

44. Mapping a MySQL Set    forum.hibernate.org

hey guys, is there anyone who can explain how to map the MySQL datatype SET? I tried building a "," separated string but it doesn't work. Any hints? The problem is NOT to map a Java Set, the problem is to map a MySQL Dataset back to Java. Thanks and regards, chris

45. Problem Mapping MySQL Time field    forum.hibernate.org

46. Mapping a URL property to mysql    forum.hibernate.org

...