spring – Can`t delete parent from ManyToOne Relationship

I have 2 entities :


@Entity
@Table
@Validated
public class Users {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    private Long user_id;

    @Column
    private String email;
    @Column
    private String name;
    @Column
    private String password;

    @OneToOne(cascade = {CascadeType.REFRESH, CascadeType.MERGE, CascadeType.PERSIST})
    private Role role;

and the second :

@Entity
@Table(name="meetings")
public class Meeting {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    private Long id;

    @Column
    @NotEmpty(message = "Start time of the meeting must not be empty")
    private String meetingStartTime;

    @Column
    @NotEmpty(message = "End time of the meeting must not be empty")
    private String meetingEndTime;

    @ManyToOne(cascade = CascadeType.ALL)
    @JsonBackReference
    private Users user;

When i try to delete Users i got an error :
Referential integrity constraint violation: “FK5U0YJ1PDS68LNFC1NVRPACJ9D: PUBLIC.MEETINGS FOREIGN KEY(USER_USER_ID) REFERENCES PUBLIC.USERS(USER_ID) (5)”; SQL statement:
delete from users where user_id=? (23503-200)

Is there a problem with casacade or what ?

physics – Unity Ragdoll moves away from parent

So this is a weird one. I’ve looked it up but can’t find anyone with similar issues. Basically I have a simple combat system and after the enemy health is zero I go through each rigidbody component in the enemy object and add a force to make it go flying on death. For some reason, the parent object isn’t affected and stays still while the Skeleton goes flying. Does anybody know how to make the parent object follow the skeleton, or make the skeleton follow the parent because as of now they act as separate entities? I’ve tried just adding force to the parent but that only moves the parent object and none of the children. Would appreciate any advice! Thanks.

Overriding a shared function from parent theme on a specific template file

My parent theme has several block styles for articles (eg. post-block-a, post-block-b, etc.), each one displaying a different UX.

In my child theme, I want to apply a change to a function that is shared across all post blocks but only on the specific block I’m using (eg. post-block-i).

I basically want to remove the <?php presso_the_category(); ?> and replace with <?php presso_the_author(); ?>.

I’ve read about adding a function to functions.php in the child theme to check if a function exists so that it get overridden. However, I don’t want to override the shared function, only the one on the specific post-block-i I’m using.

How can I potentially achieve this?

Thanks!

customs and immigration – EEA Family permit – for parent

The requirements for applying are as follows:

You can apply for an EEA family permit to come to the UK if both the following apply:

  • you’re from outside the European Economic Area (EEA)
  • you’re a ‘close’ or ‘extended’ family member of an EEA or Swiss national (excluding UK nationals)

Since Sri Linka is not in the European Economic Area, your dad meets the first requirement.

As for the second requirement, there are specific rules as to what qualifies as a ‘close’ or ‘extended’ family member:

You must be the EEA citizen’s spouse or civil partner, or related to
them (or to their spouse or civil partner) as their:

  • child or grandchild under 21 years old, or dependent child or grandchild of any age
  • dependent parent or grandparent

So your dad has to be your dependent parent or grandparent to qualify.

To be eligible, you must meet other requirements as you have been living in the UK for more than 3 months:

If they’ve been in the UK for more than 3 months they must either:

  • be a ‘qualified person’ (working, looking for work, self-employed, studying or self-sufficient)
  • have a permanent residence document – sometimes called a ‘document certifying permanent residence’

If you don’t meet any of thise two requirements for some reason, your dad must apply for the EU Settlement Scheme:

If your family member is not a ‘qualified person’ and does not have a permanent residence document, you may be eligible for an EU Settlement Scheme family permit instead.

hooks – how to add attributes of the parent taxonomy in the DOM?

I am displaying a taxonomy “category” on a node, a view of that node ,and a search facet.

This taxonomy has 2 levels.

How can i add to the rendered HTMLs, i guess using preprocessing hooks, an attribute indicating the taxonomy parent id ?

I would need to apply CSS differently to the taxonomy buttons depending on the parent.

8 – How to define an internal link as parent in mymodule.links.menu.yml?

How do I create a menu link programmatically to a node that I can use as a parent for other links?

In MYMODULE.links.module, I defined some links for my navbar:

MYMODULE.parent-fruits:
  title: 'Fruits'
  url: internal:/fruits
  weight: 0
  menu_name: food
MYMODULE.fruits-apple:
  title: 'Apple'
  parent: MYMODULE.parent-fruits
  route_name: view.fruits.apple
  weight: 5
  menu_name: food
MYMODULE.parent-vegetables:
  route_name: view.vegetables.page-main
  weight: 10
  menu_name: food
MYMODULE.vegetables-asparagus:
  parent: MYMODULE.parent-vegetables
  title: 'Asparagus'
  url: internal:/admin/structure/taxonomy/manage/card_group_private/add
  weight: 5
  menu_name: food

In this case, I expect to have a menu that looks like this:

  • Fruits (child-> Apple)
  • Vegetables (child-> asparagus)

When I go to the parent page, the link to the child should appear in the navbar menu (the parent tree should be expanded).

But what I actually get is:

  • Fruits (no children)
  • Vegetables (child-> asparagus)

The problem is caused by defining the menu link with url instead of route_name. I know this because when I change the parent of fruits-apple to parent: MYMODULE.parent-vegetables, then I see Apple as a child of Vegetables.

When I remove parent from Apple, then it appears in the menu (without a parent), so I know the link is defined correctly.

I can also create the Fruits / Apple links in the menu UI, and those work correctly.

Regarding parent: the documentation says this:

Determining the parent menu_link name can be a little tricky at first.
If you know the path of the parent menu item, you would need to search
for it in all available *.routing.yml files (most text editors and
IDEs should allow you to search all files in a project) and find the
route name for that path. Then, you would need to search for the route
name in all available *.links.menu.yml files. The menu_link whose
route_name matches is your link. Alternatively, if you know which
module is defining the parent menu link (or one of the parent menu
link’s children), you can go straight to that module and perform your
search.

Since these are node links, I checked node.routing.yml in the core node module, but I couldn’t find the route to node pages.

So: how do I create a menu link programmatically to a node that I can use as a parent for other links?

views – List of parent and child taxonomies and related content

I would like to show in the front page a list of dishes. Like a real restaurant menu, I would like see:

Wines

 -Whites

  --Product 1

  --Product 2

 -Reds

  --Product 3

  --Product 4

Beers

 -Blondes

  --Product 5

 -Reds

  --Product 6

and so on.

To do so, I created a taxonomy vocabulary named category and then a list of terms and sub-terms like this:

taxonomies

Then in my custom type Product I created a relation field to the taxonomy category.
But when I tried to create a custom view to list all the products by taxonomy terms and sub-terms, I only view the child one.
How can I create the view to display the complete hierarchy list?
Thanks

pagination – Next and Previous Posts of Same Parent

I’m working on a website for a webcomic and I have a custom post type set up for comic pages. I have multiple series on the site and have made each comic page a child post of a parent (one parent for each series) to keep them organized and give the URLs some structure. What I’m trying to do now is add next and previous buttons to each comic page so the reader can easily move between them. I’m currently having two separate but related issues.

1. The comic pages use the same name and URL format, only separated by their parent. So for example the first page of series LCC looks like this:

http://localhost/wordpress/comics/lcc/v01-001/

Whereas the first page of series HTA looks like this:

http://localhost/wordpress/comics/hta/v01-001/

WordPress allows this at a URL/slug level but it creates problems when trying to use the next and previous post functions. What happens is that the children of the parent which was created first (in this case LCC) take priority, which works perfectly when moving back and forward within LCC. However if I go to a page from HTA and try to move back and forward in there, it immediately kicks me out to the page with the appropriate slug but in LCC (so for example clicking “next” on hta/v01-001 should lead to hta/v01-002, but instead leads to lcc/v01-002 – clicking “previous” then leads to lcc/v01-001).

I’ve found some solutions that do away with the next/previous post functions and do it by incrementing the post ID, but that won’t work for me because I’ve set it up to paginate by menu order, which I’ve changed to be alphabetical (I want this all to work independently of post ID number). Here’s the code I used for that:

/* === Reorder Comic Page Pagination Alphabetically === */
function filter_next_post_sort($sort) {
    global $post;
    if (get_post_type($post) == 'comic-page') {
        $sort = "ORDER BY p.post_title ASC LIMIT 1";
    }
    else{
        $sort = "ORDER BY p.post_date ASC LIMIT 1";
    }
    return $sort;
}

function filter_next_post_where($where) {
    global $post, $wpdb;
    if (get_post_type($post) == 'comic-page') {
        return $wpdb->prepare("WHERE p.post_title > '%s' AND p.post_type = '". get_post_type($post)."' AND p.post_status = 'publish'",$post->post_title);
    }
    else{
        return $wpdb->prepare( "WHERE p.post_date > '%s' AND p.post_type = '". get_post_type($post)."' AND p.post_status = 'publish'", $post->post_date);
    }
}

function filter_previous_post_sort($sort) {
    global $post;
    if (get_post_type($post) == 'comic-page') {
        $sort = "ORDER BY p.post_title DESC LIMIT 1";
    }
    else{
        $sort = "ORDER BY p.post_date DESC LIMIT 1";
    }
    return $sort;
}

function filter_previous_post_where($where) {
    global $post, $wpdb;
    if (get_post_type($post) == 'comic-page') {
        return $wpdb->prepare("WHERE p.post_title < '%s' AND p.post_type = '". get_post_type($post)."' AND p.post_status = 'publish'",$post->post_title);
    }
    else{
        return $wpdb->prepare( "WHERE p.post_date < '%s' AND p.post_type = '". get_post_type($post)."' AND p.post_status = 'publish'", $post->post_date);
    }
}

add_filter('get_next_post_sort',   'filter_next_post_sort');
add_filter('get_next_post_where',  'filter_next_post_where');
add_filter('get_previous_post_sort',  'filter_previous_post_sort');
add_filter('get_previous_post_where', 'filter_previous_post_where');

And my custom post code:

/* === Comic Page === */
function post_type_comic_page() {
    
    // Labels
    $labels = array(
        'name' => 'Comic Pages',
        'singular_name' => 'Comic Page',
        'add_new' => 'Add New Comic Page',
        'add_new_item' => 'Add Comic Page',
        'all_items' => 'All Comic Pages',
        'edit_item' => 'Edit Comic Page',
        'not_found' => 'No Comic Pages Found',
        'not_found_in_trash' => 'No Comic Pages Found in Trash',
    );
    
    // Arguments
    $args = array(
        'labels' => $labels,
        'public' => true,
        'menu_icon' => 'dashicons-book-alt',
        'hierarchical' => true,
        'exclude_from_search' => false,
        'has_archive' => true,
        'publicly_queryable' => true,
        'rewrite' => array( 'slug' => 'comics', 'with_front' => false ),
        'supports' => array(
            'page-attributes', 'title', 'editor', 'something-else',
        ),
    );
    
    // Register Comic Pages Post Type
    register_post_type('comic-page', $args);
}

add_action('init', 'post_type_comic_page');

2. When I solve that problem, I then need to be able to restrict forward and backward navigation to only the siblings under the same parent. So upon reaching the last page of LCC, it should NOT go to the first page of HTA, or vice-versa.

My fallback option for all this is to just use a series taxonomy (which I had set up previously and worked), but I’m trying to eliminate as much unnecessary code and as many necessary things to check on each comic page as possible. I can do literally everything else I need to without a taxonomy just for that, so if it’s at all possible to do this with child/parent relationships please help me out!

unity – Position/orient parent to place child at a particular position/orientation

If you want a parent world rotation$P_W$ that takes the child local rotation $C_L$ to the provided child world rotation $C_W$, we can express that as an equation:

$$C_W = P_W cdot C_L$$

Then you can simply solve for the parent rotation algebraically:

$$C_W cdot C_L^{-1}= P_W cdot C_L cdot C_L^{-1} = P_W cdot I = P_W$$

So, parent.rotation = childTargetWorldRotation * Quaternion.Inverse(child.localRotation);

(Note that the order of the multiplication here is important – putting the inverse on the left side of the multiplication does not produce the same rotation, in general)

Now that we know the rotation, we can work out how that transforms the parent-to-child vector:

Vector3 worldOffset = parent.TransformVector(child.localPosition);

And then reverse that vector to find where to place the parent:

parent.position = childTargetWorldPosition - worldOffset;