Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7851679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:14:19+00:00 2026-06-02T19:14:19+00:00

Using JPA and Hibernate I have an entity class @Entity @Table(name = "ROLES") public

  • 0

Using JPA and Hibernate
I have an entity class

@Entity
@Table(name = "ROLES")
public class Role implements Serializable 
{
       
   @Column
   private List<String> tubes;    

// another fields .setters, getters  
}  

Every String in List tubes – is one row from another table (TUBES).

Table ROLES has an OneToMany relationship with TUBES.
A can make another Entity Tubes and map table TUBES on Entity Tubes. But how I can make this without another entity?

Edit:

I made

 @ElementCollection
 @CollectionTable(name = "TUBES", joinColumns = @JoinColumn(name = "role_id"))
 @Column(name = "tube")
 private ArrayList<String> tubes;  

Deploy on JBoss. And in runtime I get SQLGrammarException

Query created by JPA is:

/* SELECT r FROM Role r WHERE r.name = ? */ select role0_.AA_ID as AA1_0_, role0_.ROLNAME as ROLNAME0_, role0_.role as PID4_0_ from PIDDB_PID_ROLE role0_ where role0_.ROLNAME=?
17:17:14,661 ERROR [JDBCExceptionReporter] ORA-00904: "ROLE0_"."tube": invalid identifier

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:14:21+00:00Added an answer on June 2, 2026 at 7:14 pm

    You can use @ElementCollection mapping I think this is what are you looking for.

    @ElementCollection(fetch=FetchType.LAZY)
    @CollectionTable(name="TUBES", joinColumns=@JoinColumn(name="role_id"))
    @Column(name="tube")
    private List<String> tubes;    
    

    Update:

    dependency>
      <groupId>org.hibernate.javax.persistence</groupId>
      <artifactId>hibernate-jpa-2.0-api</artifactId>
      <version>1.0.0.Final</version>
    </dependency>
    
    **Update2:**
    
    import javax.persistence.CollectionTable;
    import javax.persistence.Column;
    import javax.persistence.ElementCollection;
    import javax.persistence.Entity;
    import javax.persistence.FetchType;
    import javax.persistence.GeneratedValue;
    import javax.persistence.Id;
    import javax.persistence.JoinColumn;
    import javax.persistence.Table;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an JPA entity like this: @Entity @Table(name = category) public class Category
I'm using JPA 2 with Hibernate 3.x. I have two Entity objects Foo and
I'm using Hibernate/JPA and have an @Entity object called Order, pointing at a MySQL
We have a setup where we are using an embedded HSQLDB for backing Hibernate/JPA
JPA/Hibernate missing column I am using JPA with Hibernate as the provider. I had
I'm using JPA (Hibernate's implementation) to annotate entity classes to persist to a relational
When I make relationsships with JPA using hibernate, some terrible long and ackward column
I am new to JPA/Hibernate. Currently using EJB3, Hibernate/JPA. I have an inheritacnce structure
I've mapped two entities using JPA (specifically Hibernate). Those entities have a one-to-many relationship
I have build my data model using JPA and am using Hibernate's EntityManager 3

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.