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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:36:27+00:00 2026-05-21T22:36:27+00:00

I’m creating a an entity with 2 one-to-many relationships. An Event has a User

  • 0

I’m creating a an entity with 2 one-to-many relationships. An Event has a User field and a Place field. I’m trying to use the automatic-query, but this code always returns an empty list.

    User user = new User("mauriziopz@gmail.com","Maurizio Pozzobon","01","hash","facebook");
    user.insert();
    Place place = new Place("posto","bel posto",null,null);
    place.insert();
    Event e =new Event(user,place, "Festa","Questa è una gran bella festa",null,new Date(),(long) 10,false,null);
    e.insert();
    List<Event> l =user.events.fetch();

The Event class is

public class Event extends Model{
    @Id
    public Long id;

    ...

    //Relazioni
    public User user;
    public Place place;

        ...

    public Event(User user, Place place,String nome, String descrizione, String uRLImmagine, Date dataInizio, Long durata, Boolean isRicorrente, Long ricorrenza) {
        this.user=user;
        this.place=place;
        ...
    }
        ...
}

If I change the Event class like this

public class Event extends Model{
    @Id
    public Long id;

    ...

    //Relazioni
    public User user;
    //public Place place;

        ...

    public Event(User user, Place place,String nome, String descrizione, String uRLImmagine, Date dataInizio, Long durata, Boolean isRicorrente, Long ricorrenza) {
        this.user=user;
        //this.place=place;
        ...
    }
        ...
}

The same code above returns a list with one Event in it (what I expected)

Edit: This is the Place class

public class Place extends Model {



@Id
public Long id;

public String nome;
public String descrizione;
public String uRLImmagine;
public String indirizzo;


//Relazioni
// public User user;
//@Filter("place")
//public Query<Event> events;
private Set<Long> idEvents = new HashSet<Long>();
private Set<Long> idPlaceVotes = new HashSet<Long>();
private Set<Long> idPlaceComments = new HashSet<Long>();


public Place(/*User user,*/ String nome, String descrizione, String uRLImmagine,String indirizzo) {
//  this.user=user;
    this.nome = nome;
    this.descrizione = descrizione;
    this.uRLImmagine = uRLImmagine;
    this.indirizzo = indirizzo;
}


static Query<Place> all() {
    return Model.all(Place.class);
}

public static Place findById(Long id) {
    return all().filter("id", id).get();
}

public String toString() {
    return nome;
}  

public static void delete(Long id) {
    findById(id).delete();

}

}

This is the User class

public class User extends Model {

@Id
public Long id;

public String nome;
public String email;
public String webId;    //ID of the user in the provider website
public String passwordHash;
public String service;

//Relazioni
@Filter("user")
public Query<Event> events;

public User(String email, String name,String webId, String passwordHash, String service) throws Exception {
    if (email!=null)
        this.email=email;
    else
        throw new Exception("An email is required");
    if (name!=null)
        this.nome=name;
    else
        throw new Exception("A name is required");

    if (webId!=null)
        this.webId=webId;
    else
        throw new Exception("A webId is required");

    this.passwordHash=passwordHash;
    this.service = service;
}

public void setEmail(String email) throws Exception{
    if (email!=null)
        this.email=email;
    else
        throw new Exception("An email is needed");
}

static Query<User> all() {
    return Model.all(User.class);
}

public static User findById(Long id) {
    return all().filter("id", id).get();
}

public static User findByEmail(String email){
    return all().filter("email", email).get();
}

public String toString() {
    return nome;
}

}

MyModel was a super class of siena.Model, but right know it doesn’t do anything useful so I changed it back to Model.
I’m using play-siena 1.5 on play 1.1

  • 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-05-21T22:36:28+00:00Added an answer on May 21, 2026 at 10:36 pm

    I found your problem 🙂

    This is a known issue but I forget it each time.
    In your event, simply declare the @Column:

    public class Event extends Model{
        @Id
        public Long id;
    
        @Column("user")
        public User user;
    
        @Column("place")
        public Place place;
    }
    

    As User and Place have each a key field named “id” and the key field name is used by default by Siena when there is no @Column, there is a collision when GAE tries to find the object by field “id”.
    I will try to correct this in Siena v1.0.0 (and you can already use siena.jar generated from v1.0.0 trunk transparently in Play)

    regards
    Pascal

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

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the

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.