Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceptions are thrown when using reverse associations #38

Open
omaroman opened this issue Dec 1, 2011 · 0 comments
Open

Exceptions are thrown when using reverse associations #38

omaroman opened this issue Dec 1, 2011 · 0 comments

Comments

@omaroman
Copy link

omaroman commented Dec 1, 2011

I have the following escenario:

Author <- Quote (quote has a reference to author)

@MappedSuperclass
public class AuthorAbs extends Model {

// REVERSE ASSOCIATION

@OneToMany(mappedBy = "author", cascade = CascadeType.ALL, fetch = FetchType.LAZY) // name of the variable in the other object that references this object
public List<Quote> quotes = new ArrayList<Quote>(); // has_many :quotes

// FIELDS

@Required
public String first_name;

@Required
public String last_name;

}

@entity
@table(name = "authors")
@ElasticSearchable
public class Author extends AuthorAbs {
public int years;
}

@entity
@table(name = "quotes")
@ElasticSearchable
public class Quote extends Model {

// Associations

@ManyToOne() // Optional, targetEntity for indicating where's the relationship
@JoinColumn(name = "author_id") // name of the FK field in this table
// --
@Required
public Author author;   // belongs_to_one :author


// Fields

@Required
public String quotation;

}


When updating an Author that has at least one Quote, throws the exception

12:34:22,451 ERROR ~
java.io.IOException: Type not allowed [class models.Quote]
at org.elasticsearch.common.xcontent.XContentBuilder.value(XContentBuilder.java:698)
at play.modules.elasticsearch.mapping.impl.CollectionFieldMapper.addToDocument(CollectionFieldMapper.java:94)
at play.modules.elasticsearch.mapping.impl.PlayModelMapper.addModel(PlayModelMapper.java:130)
at play.modules.elasticsearch.mapping.impl.PlayModelMapper.addModel(PlayModelMapper.java:26)
at play.modules.elasticsearch.adapter.ElasticSearchAdapter.indexModel(ElasticSearchAdapter.java:147)
at play.modules.elasticsearch.ElasticSearchIndexAction.invoke(ElasticSearchIndexAction.java:53)
at play.modules.elasticsearch.ElasticSearchIndexer.doJob(ElasticSearchIndexer.java:54)
at play.jobs.Job.doJobWithResult(Job.java:50)
at play.jobs.Job.call(Job.java:146)
at play.jobs.Job$1.call(Job.java:66)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

There's a full app in https://github.com/omaroman/recordtracking/tree/master/samples-and-tests/demo

bgooren added a commit to bgooren/playframework-elasticsearch that referenced this issue Dec 5, 2011
@bgooren bgooren mentioned this issue Dec 5, 2011
iskra-vitaly added a commit to iskra-vitaly/playframework-elasticsearch that referenced this issue Mar 6, 2012
* org_elastic/master: (28 commits)
  0.4 release
  Add MapperTransformer
  Use AbstractFieldMapper#getFieldValue()
  Some refactoring; Mapper prefix folded into AbstractFieldMapper
  feliperazeek#32 Added a transformer which uses a mapper
  Make sure the user has not requested unknown fields
  Minor restructuring
  Made AFM#addField() non-static so we can access meta directly
  Log json for index operation
  Fix for feliperazeek#36 (Class references not cleaned up on hot reload)
  Fix for feliperazeek#38 (@onetomany causes "Type not allowed" exception)
  Fix for feliperazeek#34 (cannot parse indexed date on record retrieval)
  Upgrade to ES 0.18.5
  Fix for feliperazeek#37 (do not index @transient fields)
  Fixed elasticSearch tag path (fixes bug in _at least_ 1.2.4-RC3)
  Fixed route indentation to make file more readable
  Add support for Float conversion to ReflectionUtil
  Releasing 0.3
  setQuery(QueryBuilder) is available from es-0.17.0 (See ES issue 994)
  Log type mapping
  ...

Conflicts:
	conf/routes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant