TYPO3 Extension Error: Cannot create empty instance of the class - typo3

My FE plugin created using extension builder shows me the following error :
Cannot create empty instance of the class "TYPO3\CMS\Extbase\Persistence\ObjectStorage" because it does not implement the TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface.
What does it mean and how do I resolve it?
TYPO3 version 6.1.0
My Domain Object named Subject has relations Category_Id m:n relation and Location_Id 1:n relation . I did not map these two to any table during the creation of the extension.
How do I mention this in the extension that these relations are related to certain tables (Category_table and Location_table)and are to be looked in their respective domain model objects to retrieve data ?
The problem is a little confusing, I hope I made myself clear
Thank You

You need to set up the relation within the TCA.
Make sure to clear the cache and to remove the typo3temp/Cache/.
Then you will need to annotate your model properly such that extbase can resolve the reference.
Remember: TCA for core and annotation for extbase

Related

Using the same entity type for multiple entity sets (Entity FrameWork)

I have a table and a view which share the same columns and I'm trying to add them to EDM. I created an abstract entity type and 2 derived types A and B.
Initially I tried creating 2 entity sets, one for each of the derived types, and proceeded to add the EntitySetMapping (using IsTypeOf per MS MSL specifications for EntityTypeMapping of derived type) but got an error in the .edmx file that each of the types doesn't have an entity set and isn't mapped.
To solve this, I created a single EntitySet with type as the base EntityType (the abstract one) and used 2 EntityTypeMapping children tags, specifying the StoreEntitySet as the table or the view accordingly. This resolved the issue but created a single DbSet<BaseType> and now I cannot retrieve data from the view or the table using DbContext.
Any ideas on how to properly solve this?
Thanks

TYPO3 Extension Builder Integrate of existing table

I tried to integrate an existing table to my extension. The problem is that the content of the table isn't taken over.
I created a new model with the name of the existing table and named the properties according to the existing column names. I also implemented the corresponding getters and setters of the properties.
Extension
The name of the existing table is tx_institutsseminarverwaltung_domain_model_event.
How are you trying to "consume" or access the data from the other table in your extension?
Do you have a repository for the existing table (maybe there is already an existing repository, that you can reuse)?
See german typo3 board mapping existing tables and SO thread TYPO3 / How to make repository from existing table fe_users?
This question is most likely a duplicate of this question
The solution for this issues is:
First get the Typo3 query settings
$querySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings');
Set RespectStoragePage to false
$querySettings->setRespectStoragePage(FALSE);
Fetch your repository
$theRepository = $this->objectManager->get('TYPO3\\institutsseminarverwaltung\\Domain\\Repository\\EventRepository');
And set the query settings to your repository.
$theRepository->setDefaultQuerySettings($querySettings);

Rails 5.1.2 - Single Table Inheritance: No migration is getting generated

I am trying to generate scaffolding for STI implementation. I issue the following.
rails g scaffold user1 type name email
rails g scaffold member company subscription --parent user1
Every thing gets generated file except for the migration file my 'member' model.
When I try to create a member record like this
Member.create(name: "My Name", email: "myname#example.com",
company: 'Example LLC', subscription: 'Monthly Gold' )
I get this error:
ActiveModel::UnknownAttributeError: unknown attribute 'company' for Member. from (irb):1
Any ideas on what is going on?
I use rails 5 and db is postgres
The --parent option assumes that you are already all setup for single table inheritance, i.e. the parent class has a table with a type column (or whatever column you are using for this).
Since the model will be stored in the parent's table, there is no need to create a new table for the subclass, hence no migration
I got this answer similar to this question asked by someone.
To my understanding, you are on the wrong track. In single table inheritance, all the attributes must be present in the parent model table with an additional column name 'type' to indicate the type of inherited model. The column name 'type' can be changed with appropriate settings but ActiveRecord by default looks for 'type' column. You are getting 'UnknownAttributeError' error cause the parent model does not have the following column in its table. You need to write a migration to add the new columns. Hope you understand the concept of STI. For further exploration, I am providing you the link of the official guide. Hope your problem will be solved.
http://edgeguides.rubyonrails.org/association_basics.html#single-table-inheritance

jhipster - JPA entity with self reference

I am trying out jhipster and I wonder how to define a self reference within an entity.
Something like: a "topic" has a field refering itself as parent or child. Going through the generator I did not see a possibility to do so.
That`s why I generated a topic entity and added a field myself in the entity, howevever, it seems like changes in the entity are not picked up by liquibase.
Readint the docs it seems like the topic.json file from jhipster is parsed for this, but, that does not support the self reference. So I am kind of stuck here.
Any ideas how to achieve what I want?
Thanks,
Sven
liquibase creates the database tables using changelogs.
Look into the resources/config/liquibase/changelog folder
there should be a file named like "201531081212_added_entity_Topic.xml"
when you're adding properties, you have to change the table description of this changelog.
normally, it would be better to create a new, additional changelog when adding/removing columns or tables. This should contain somthing like this:
<addColumn tableName="TOPIC">
<column name="topic_id" type="bigint"/>
</addColumn>
or parent_id or how you named the field in the entity class.
asfair there are also some maven goals as part of the maven liquibase plugin to generate a new changelog.
Changing/Migrating entities is not yet supportet well by jhipster...

Extbase looking for wrong table

I'm using TYPO3 7.4.0 and I'm learning to build extensions in extbase & fluid.
I have a vendor prefix in my table names. I create three tables for my extensions. When I go in the backend and add entities in the list view on the resource folder I created, it works without any problems. When I go to the Frontend to view the index action of my entity it looks for a table without the vendor prefix in it's name. Does anyone know what that means? I create the tables in the "ext_tables.sql". I have no table mapping defined. I don't know where to change which tables extbase is looking for.
By default Extbase looks for table using schema tx_extkey_domain_model_modelname, so for Animal model in zoo ext it will be tx_zoo_domain_model_animal. (extkey without underscore if any!)
If you used other schema (like vendor name within table name) you need to use mapping. I.e. create file ext_typoscript_setup.txt in main folder of your ext and use this:
config.tx_extbase{
persistence{
classes{
Vendor\Zoo\Domain\Model\Animal {
mapping {
tableName = tx_your_own_name
}
}
}
}
}
BTW: it's best idea to keep the original naming schema. Other thing is that creating extensions manually can be tricky - at least for beginners, install Extension Builder ext to fast kickstart new extensions just with click-click way.