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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:11:17+00:00 2026-06-12T19:11:17+00:00

I am currently programming a board for me and my friends with the playframework

  • 0

I am currently programming a board for me and my friends with the playframework 1.2.4 that uses the JPA.
Everything was fine until I came to the view mechanism.

The problem is, that every user can have multiple view entries.
Every topic can also have multiple view entries so here is my view model:

@Entity
public class ForumTopicView extends Model
{

    @Required
    @ManyToOne
    public ForumTopic   topic;

    @Required
    @ManyToOne
    public User         user;

    @Required
    public Date         viewDate;

}

On the other hand, there is only one view for a topic AND the connected user.

Here is my topic model:

@Entity
public class ForumTopic extends Model
{

    // ...

    @OneToOne(mappedBy = "topic") // TODO: and the connected user
    public ForumTopicView       view;

    // ...
}

How can I customize this that the user has to be the connected user and for every topic only one view selected is.

Thanks for any help!!
MRu

@Yogendra Singh: Yes thats correct. Every user can have a view to one topic.

  • 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-12T19:11:18+00:00Added an answer on June 12, 2026 at 7:11 pm

    If one side of an association is a ManyToOne, the other side must be a OneToMany, not a OneToOne.

    Every topic has multiple views (and one of these views is for the current user). Each user has multiple views (and one of these views is for a given topic). So you have two OneToMany/ManyToOne associations.

    It’s not clear what you want to do, but I think you’ll need to execute a query to get what you want. If what you want is the list of views associated with the current user and corresponding to a given list of topics, the query simply is

    select view from ForumTopicView view
    where view.user = :currentUser
    and view.topic in (:listOfTopics)
    

    No need for 50 queries if you have 50 topics. The above one retrieves all the views at once.

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

Sidebar

Related Questions

I'm currently programming an app for iphone that uses the tab bar. One of
I'm currently programming a phong spot-light shader that uses the new ogl3 feature, ubos.
I am currently working on a programming related problem where I am attempted to
I'm currently programming a web application that can be embedded. I'm wondering if it
I'm currently programming an application that manages parallel rendering on several computers. For that,
I am currently programming a python-based datagram-Server using threads and all of that. I
I am currently programming an ASP .NET FormView. The twist here is that I
I am currently programming a game that requires reading and writing lines in a
I'm currently programming a UDP application which allows clients to login. After that, their
i'm currently programming a board game (8x8) in which I need to develop an

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.