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 8554987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:00:53+00:00 2026-06-11T15:00:53+00:00

I have a pretty stupid question. Is it possible to have a direct relation

  • 0

I have a pretty stupid question.

Is it possible to have a direct relation that only pulls back a single column from the child relation…
example…

@Table(name="AUTH")
public class Magazine {

    @Column(length=9)
    @Id private String isbn;
    @Id private String title;

    @OneToOne
    @JoinColumn(name="COVER_ID" referencedColumnName="ID")
    private string coverArticle; //<--- I want this to just have the Article Name... How can this be done

    ...
}

See that oneToone annotation above. I want that to just contain the string of the Article name…

@Table(name="ART")
public class Article {

    @Id private long id;

    @Id private String ArticleName;
}

I know you can have an ElementCollection where you get a collection of Elements from another table, how do you get a single value back into that element?

  • 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-11T15:00:54+00:00Added an answer on June 11, 2026 at 3:00 pm

    This is probably not as simple as you were hoping, but you can do this by defining a FetchGroup on your entities. For the example you gave above, you could modify it as follows:

    @FetchGroups({
        @FetchGroup(name="coverArticleNameOnly", attributes={
            @FetchAttribute(name="isbn"),
            @FetchAttribute(name="title"),
            @FetchAttribute(name="coverArticle"),
            ...
        })
    })
    @Table(name="AUTH")
    public class Magazine {
    
        @Column(length=9)
        @Id private String isbn;
        @Id private String title;
    
        @OneToOne
        @JoinColumn(name="COVER_ID" referencedColumnName="ID")
        private string coverArticle;
    
        ...
    }
    
    @FetchGroups({
        @FetchGroup(name="coverArticleNameOnly", attributes={
            @FetchAttribute(name="articleName")
        })
    })
    @Table(name="ART")
    public class Article {
    
        @Id private long id;
    
        @Id private String ArticleName;
    }
    

    Then, before you retrieve your Magazine record, make the following call:

    getEntityManager().getFetchPlan().addFetchGroup("coverArticleNameOnly");
    

    The unfortunate part, as you can see above, is that you need to add fetch attributes to your fetch group for all of the fields in the Magazine class that you want to keep.

    For more information see http://openjpa.apache.org/builds/1.0.4/apache-openjpa-1.0.4/docs/manual/ref_guide_fetch.html.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since I'm pretty new this question'll certainly sound stupid but I have no idea
So I've got a pretty stupid question. Is it possible, to create a div
I'm pretty new to Objective-C, switching over from C++, so excuse my stupid question.
i have pretty simple simple question (i hope so). How do i change the
I might have pretty basic question about regex. I have the following regex, which
I have a pretty large object that I need to pass to a function
This may be a pretty naive and stupid question, but I'm going to ask
I think my question is pretty stupid, but here it goes: I am using
I am pretty new in SQL so this may be a stupid question... I
I apologise for what I'm pretty sure is a fairly stupid question, but I

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.