Suppose I have this database model in extbase:
model A
- property
- n:1 relation to model B
model B
- property
- n:1 relation to model C
model C
- property
Can I achieve something like this in the backend form of model A?
instance of model B 1
[] good [] bad
instance of model B 2
[] good [] bad
and so on.
Short, I want to set the values for the property of model C in the form of model A for all instances of model B. Is there a way to do this in the TCA configuration or with a nested flexform?
Yes, that is possible. Although I think you want to do that in Model C (or I misunderstood you or 1,n are mixed up). I assume C 1<=>n B 1<=>n A.
Have a look at the inline column type https://docs.typo3.org/m/typo3/reference-tca/master/en-us/ColumnsConfig/Type/Inline.html, also referred to as "IRRE" (inline relational something). This allows to create and edit sub-records inline. Check out the column types group and select, too. They are suitable for 1..n:n relations, too.
This works in TCA and Flexform (for Model C). Persistence IIRC in IRRE must be done to the DB (as opposed to a flexform string like e.g. tt_content.pi_flexform), so Model B and A should be TCA-defined and have tables.
Related
I'm learning nest.js with postgresql and I'm stuck on the one subject. Let's suppose I have three entities: entity A, B and C.
I want one of the field from the entity C to reference either to A or B.
At this moment I could set two different columns, where one refers (as one to many) to entity A, and another column to entity B.
Is there any way I could sort it out having only one column for that?
Like
#One-To-Many(ref to A | B)
We use Eclipselink-2.6 with wildfly-8 server in a JavaEE7 application.
we have three JPA entities A, B, and C.
B and C extend A.
In order to change the type of an object "myObjectId" A to B, we try to:
1- Change the dtype value from "a" to "b" in Table "A" for the instance "myObjectId" using the criteria query.
2- Create a new row in the table "B" in the database for the same id "myObjectId" also with a criteria query.
3- Clearing the cache by evictAll as well Entitymanger using clear functions.
After, when I tried to find all data of type B, the object "myObjectId" came in the list but with type A!
After restarting wildfly server and call findAll, therefore, the data came with type B!
why myObjectId didn't change its type even if the first and the second level cache was cleared!?
See https://wiki.eclipse.org/EclipseLink/Examples/JPA/Caching
Essentially EclipseLink maps the JPA cache eviction call to its own invalidation logic, which seems to be keeping a reference to the object using a soft reference so that object identity is maintained. This prevents A1->B1->A1' from happening on cycles with lazy relationships.
Try calling ((JpaEntityManager)em.getDelegate()).getServerSession().getIdentityMapAccessor().initializeAllIdentityMaps() as suggested in the doc and then reading in the changed class.
I have a 1:n relation between two model objects: MainAuthor and Book. I created my domain model with the Extension Builder and I need to get the MainAuthor in the Book class, just like this: TYPO3 Extbase bidirectional 1:n relation
I followed the instructions, but book->getMainAuthor() returns null. Is there something else I should do?
Did you name your property correctly in Book (should be $mainAuthor)?
Did you empty your caches?
I have an ERD with a main table (A) which has one attribute(String) that is a FK to another table (B).
The issue that I have is that in B the only attribute is the PK; I just want to ensure that the user inputs only one of the allowed values in the main table attribute. I do not even want to update the B table from the application, as it will be a task so unusual that I'll do it directly in the DB.
I could treat B just as another Entity and deal with them with "regular" JPA, but I am a little troubled that maybe there are more efficient ways to do it*. All I want from B table is to get the full list of values and to ensure that the attribute value is correct.
So the question is: there is a specific pattern in JPA to deal with those master tables?
Thanks In advance.
*: My concern is creating / retrieving Entity B objects when all that it is needed is an string, every time an Entity A object is created retrieved.
I would simply use a native query to get all the strings from the B table, or map B as an entity to retrieve all the B Strings using a JPQL query, but not have any association from A to B.
The B string would be stored as basic String column in entity A. And if you try creating or updating an A instance with a string that is not in the B table, then you'll get an exception at flush or commit time because the foreign key constraint is broken.
I want to know if there is way to create a database out of existing classes with the ado.net entity framework or to map existing classes to a database.
I looked for tutorials and only found ways to create the classes with the entity model designer.
As an example I have the class Bird with Properties Length and Age
On the database I have a table named Bird with columns Length and Age
Now I don't want the designer to create new classes out of the database. Instead I want to map the Class Bird directly to the table Bird. With Linq2Sql this was possible by creating the mapping manually. Is there a possibility in the ado.net entity framework?
With kind regards
Sebastian
What's the difference between mapping a class C onto a table T or mapping T onto a class C ?
O/R mapping isn't about mapping classes to tables, it's about defining an entity model and projecting it to tables AND classes simultaneously. After all, your classes and tables don't fall out of the sky: they're based on definitions you have, e.g. there has to be an entity customer, with fields A, B and C, and THEN you're defining the entity Customer with fields A, B and C which leads to a table Customer with fields A, B and C and a class Customer with fields / properties A, B and C and the mapping between them, because they represent the same entity