Relationship Already Exists

29 views
Skip to first unread message

Alex

unread,
Jul 4, 2022, 12:15:31 PM7/4/22
to dotCMS User Group
Dear Group,

I am running 22.03 CE.  One of our users deleted by mistake  a relationship field.  This relationship field was a self-relationship.

When we try to recreate the field the system through us an error stating on the front end stating below. 

Bad Request Error

The relationship ContentTypeName.ContentTypeName already exists.

Then I get a button asking me to accept.

On the logs I get:

INFO  util.SecurityLogger - class com.dotcms.rest.exception.mapper.DotBadRequestExceptionMapper : The relationship Attraction.attraction already exists -- ip:226.263.198.111,user:XXXX

Does anyone know how to approach this problem?  It seems it only happens in contentType self-relationships because I am able to create, delete, and recreate other relationship fields without any issues.

When I check in the system, the self relationship does not exist. 


Thank you for any tip to fix this issue!

Regards,


Lex


Nollymar Longa

unread,
Jul 5, 2022, 6:28:08 PM7/5/22
to dotCMS User Group
Hi Alex, 

Did you try to flush cache before adding the field again? 

Regards,

Nolly!

Lex Medeiros

unread,
Jul 5, 2022, 6:32:10 PM7/5/22
to dot...@googlegroups.com
Nolly,

Yes, I did.  Flushing cache prior to adding the field still returns the same error message as if the relationship exists.

Lex

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/eee2fbf2-8a20-429e-bdf2-8ab4c97e38cen%40googlegroups.com.

Nollymar Longa

unread,
Jul 6, 2022, 11:23:52 AM7/6/22
to dot...@googlegroups.com
Alex, is there a relationship field on the other content type linked to this relationship? I mean the other side of the relationship 

You received this message because you are subscribed to a topic in the Google Groups "dotCMS User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dotcms/DvLCVapJvio/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dotcms+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CABzdpQmReTfSsOAC_3HUAWWBCZc3SE%3Dc%3Dni4NfyZfEZN16x3bg%40mail.gmail.com.

Lex Medeiros

unread,
Jul 6, 2022, 11:33:16 AM7/6/22
to dot...@googlegroups.com
Nolly,

No, there is not.  This is a self relationship.  So the relationship is with the contentType itself, in this case Attraction.attraction.

What I have done so far is: deleted all the relationship fields, recreated them (loaded them from back up), but I can not create the self-relationship field on the contentType.

Thanks for your help!

Lex

Lex Medeiros

unread,
Jul 6, 2022, 12:33:47 PM7/6/22
to dot...@googlegroups.com
Nolly, 

Just one detail I remember is that when the relationships were upgraded to fields.  There were two self-relationships fields built:
Attraction.attractionparents and Attraction.attractionchildren.

Not sure if that has something to do with it.  

Alex


Nollymar Longa

unread,
Jul 6, 2022, 5:08:10 PM7/6/22
to dot...@googlegroups.com
Ok Alex, let me see if I got it: it's coming from an upgrade where you had a legacy self-relationship and migrated to self-relationship field, right? 

Probably the database got messed up during the migration process. I suggest comparing the relationship table before and after the upgrade and migration. It might give you a hint of what is wrong.

What is odd is that you can't create a self-relationship field. Have you tried using another field name? I'm attaching a screenshot of how a self-relationship field looks like when you create it. Make sure your field looks the same.

Nolly!

Screen Shot 2022-07-06 at 3.56.21 PM.png

Lex Medeiros

unread,
Jul 6, 2022, 5:26:00 PM7/6/22
to dot...@googlegroups.com

The relationship fields I got were produced by the migration. 

You can see a video of the issue here.

Loom Message - 6 July 2022 - Watch Video



Nollymar Longa

unread,
Jul 6, 2022, 6:15:04 PM7/6/22
to dot...@googlegroups.com
The field you're creating looks good. Just a couple of questions: 
- Do you have a snapshot of the relationship table before and after the migration to compare? 
- What do you see on the Relationship tab when you edit the content type? 



Lex Medeiros

unread,
Jul 6, 2022, 6:29:54 PM7/6/22
to dot...@googlegroups.com
Nolly,

The migration was too long ago back in Oct 2021!  So I have no way to get a snapshot now.

Attached you will see what I see in the relationship tab :

Screen Shot 2022-07-06 at 4.18.15 PM.png

Lex Medeiros

unread,
Jul 6, 2022, 6:33:44 PM7/6/22
to dot...@googlegroups.com
Nolly,

I am sorry I did not realize that you requested the contentlet relationship tab.

I deleted it and created a tab called Related Content, instead. So I do not have a tab called "Relationships".

Lex


Nollymar Longa

unread,
Jul 6, 2022, 6:51:40 PM7/6/22
to dot...@googlegroups.com
Alex, 

Do you have access to the current database and run: 

select * from relationship where relation_type_value like '%Attraction.attraction%'

select * from relationship where parent_structure_inode='REPLACE_BY_CONTENT_TYPE_INODE' or child_structure_inode='REPLACE_BY_CONTENT_TYPE_INODE'

There you can see if you actually have that relationship.

Nolly!



Lex Medeiros

unread,
Jul 6, 2022, 7:33:30 PM7/6/22
to dot...@googlegroups.com
Nolly,

It does not look like I have it:

Here is to the first select: select * from relationship where relation_type_value like '%Attraction.attraction%'

inode | parent_structure_inode | child_structure_inode | parent_relation_name | child_relation_name | relation_type_value | cardinality | parent_required | child_required | fixed | mod_date
-------+------------------------+-----------------------+----------------------+---------------------+---------------------+-------------+-----------------+----------------+-------+----------
(0 rows)


and for the second select: select * from relationship where parent_structure_inode='REPLACE_BY_CONTENT_TYPE_INODE' or child_structure_inode='REPLACE_BY_CONTENT_TYPE_INODE'

inode | parent_structure_inode | child_structure_inode | parent_relation_name | child_relation_name | relation_type_value | cardinality | parent_required | child_required | fixed | mod_date
-------+------------------------+-----------------------+----------------------+---------------------+---------------------+-------------+-----------------+----------------+-------+----------
(0 rows)

(END)

I tried to tweak the select command and found this: ( substituted the string of the inodes with a number and letter "x" so it is easy to read.  I deleted those relationships that appear  now in this output, but the information remained on that table. And, it seems there are many more relationships there too from other contentTypes that I have not deleted yet.

XXXX=# select * from relationship where parent_relation_name like '%attraction%';


 4x | 9x | 3x | attractions          |                     | Attraction.weathers |           1 | f               | f              | f     | 2022-06-10

 3x | 9x | ex | attraction           |                     | Attraction.reviews  |           0 | f               | f              | f     | 2022-06-10 

 1x | 9x| dx | attraction           |                     | Attraction.comments |           0 | f               | f              | f     | 2022-06-10

 fx | 9x | dx | attractions          |                     | Attraction.tours    |           1 | f               | f              | f     | 2022-06-10

Lex




Nollymar Longa

unread,
Jul 6, 2022, 8:14:14 PM7/6/22
to dot...@googlegroups.com
Alex, try this: flush cache, reindex the content type and try to add the relationship field again.

If that doesn't work, try to create the relationship field with another name.

Nolly! 

Lex Medeiros

unread,
Jul 6, 2022, 8:40:33 PM7/6/22
to dot...@googlegroups.com
Nolly,

It only worked creating the relationship with another name.  Do you know what is happening with my instance?

Lex

Nollymar Longa

unread,
Jul 7, 2022, 10:45:58 AM7/7/22
to dot...@googlegroups.com
Alex, 

Something must be messed up in your content type. It might require further research or debugging. Let's try one last thing, run this query to make sure that the old relationship field is not there: 

select * from field where structure_inode='REPLACE_WITH_CONTENT_TYPE_INODE';

If you find the conflicting relationship field, you can try to delete it. Create a backup of your database first just in case!

Nolly!

Lex Medeiros

unread,
Jul 9, 2022, 6:17:56 PM7/9/22
to dot...@googlegroups.com
Nolly,

All the results I got back are the fields that I currently have.

By the way, I saw some fields that I have always wanted to get rid off and I never used.  For example, some inherited fields from dotCMS 1.9 ...  comment counts, number of votes, etc.  Can I just delete those fields from this field table and they will go away?  I can not delete them via the backend.

Alex

Nollymar Longa

unread,
Jul 11, 2022, 10:22:39 AM7/11/22
to dotCMS User Group
Alex, 

You can delete them, but make sure you create a backup of your database first. Once the delete operation is done, flush your cache and reindex your content type.

Nolly!

Reply all
Reply to author
Forward
0 new messages